summaryrefslogtreecommitdiff
path: root/src/or/buffers.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2008-02-20 16:57:39 +0000
committerNick Mathewson <nickm@torproject.org>2008-02-20 16:57:39 +0000
commitcefe0a1959bb62fb36170dc3ff8c15b9971bb822 (patch)
tree2e47bfe6783aefbb687e99c524ab39f3c0f1fe9e /src/or/buffers.c
parent1c8bd320beed5379ab3b755d41cb2fd051858a67 (diff)
downloadtor-cefe0a1959bb62fb36170dc3ff8c15b9971bb822.tar.gz
tor-cefe0a1959bb62fb36170dc3ff8c15b9971bb822.zip
r18255@catbus: nickm | 2008-02-20 11:44:55 -0500
Add asserts and refactor some comparisons in order to fix some veracode-identified issues. Note a bug in buffers.c svn:r13618
Diffstat (limited to 'src/or/buffers.c')
-rw-r--r--src/or/buffers.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/or/buffers.c b/src/or/buffers.c
index f67f44cb6a..13fda0fb55 100644
--- a/src/or/buffers.c
+++ b/src/or/buffers.c
@@ -1019,8 +1019,10 @@ static int
buf_find_pos_of_char(char ch, buf_pos_t *out)
{
const chunk_t *chunk;
- int offset = 0;
- int pos = out->pos;
+ int offset = 0; /*XXXX020 should this be pos_absolute? Otherwise, bug. */
+ int pos;
+ tor_assert(out && out->chunk && out->pos < (int)out->chunk->datalen);
+ pos = out->pos;
for (chunk = out->chunk; chunk; chunk = chunk->next) {
char *cp = memchr(chunk->data+pos, ch, chunk->datalen-pos);
if (cp) {