diff options
author | Evan Huus <eapache@gmail.com> | 2014-04-28 12:11:35 -0400 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2014-04-28 21:02:54 +0000 |
commit | 72fc075e9a6b3ba79e49668e74a8dd187fc04f8a (patch) | |
tree | b4cde394f4913ad53ed50dbdfe73494cf9623655 /wiretap/catapult_dct2000.c | |
parent | 3765e99a07f65a34b06d9d5b3b48805750d7021f (diff) |
Fix potential invalid-reads in catapult files
As caught by CppCheck, the conditions checking that n is in bounds should
occur *before* the conditions using n as an index so that if n is out of bounds
we don't try and use it anyways.
Change-Id: I107c983153aa12203f8c88b14e1addd3807d6b6e
Reviewed-on: https://code.wireshark.org/review/1415
Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'wiretap/catapult_dct2000.c')
-rw-r--r-- | wiretap/catapult_dct2000.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/wiretap/catapult_dct2000.c b/wiretap/catapult_dct2000.c index 5121e45624..8b29a23880 100644 --- a/wiretap/catapult_dct2000.c +++ b/wiretap/catapult_dct2000.c @@ -851,7 +851,7 @@ parse_line(gchar *linebuff, gint line_length, *is_sprint = FALSE; /* Read context name until find '.' */ - for (n=0; (linebuff[n] != '.') && (n < MAX_CONTEXT_NAME) && (n+1 < line_length); n++) { + for (n=0; (n < MAX_CONTEXT_NAME) && (n+1 < line_length) && (linebuff[n] != '.'); n++) { if (linebuff[n] == '/') { context_name[n] = '\0'; @@ -1089,8 +1089,8 @@ parse_line(gchar *linebuff, gint line_length, /* Read consecutive hex chars into atm header buffer */ for (; - ((linebuff[n] >= '0') && (linebuff[n] <= '?') && - (n < line_length) && + ((n < line_length) && + (linebuff[n] >= '0') && (linebuff[n] <= '?') && (header_chars_seen < AAL_HEADER_CHARS)); n++, header_chars_seen++) { @@ -1159,7 +1159,7 @@ parse_line(gchar *linebuff, gint line_length, return FALSE; } - for (; !isdigit((guchar)linebuff[n]) && (n < line_length); n++); + for (; (n < line_length) && !isdigit((guchar)linebuff[n]); n++); if (n >= line_length) { return FALSE; } |