diff options
author | Bill Meier <wmeier@newsguy.com> | 2012-01-13 21:09:33 +0000 |
---|---|---|
committer | Bill Meier <wmeier@newsguy.com> | 2012-01-13 21:09:33 +0000 |
commit | 85c1195fe3a2c13715e6d00e2d40edd6c07b0ad0 (patch) | |
tree | de951a2e649727658c35617eb13dac8194c167b3 /file.c | |
parent | dbffa9eaefb20fee57b30c65becde2ba7cdf7e1f (diff) |
Fix Bug #6276: "Find Packet" Bug:
'The search query e.g. (ASCII or hex) "abac" doesn't find the packet(s)
containing the string "ababac".'
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6726
svn path=/trunk/; revision=40483
Diffstat (limited to 'file.c')
-rw-r--r-- | file.c | 53 |
1 files changed, 39 insertions, 14 deletions
@@ -2996,22 +2996,28 @@ match_ascii_and_unicode(capture_file *cf, frame_data *fdata, void *criterion) result = MR_NOTMATCHED; buf_len = fdata->pkt_len; - for (i = 0; i < buf_len; i++) { + i = 0; + while (i < buf_len) { c_char = cf->pd[i]; if (cf->case_type) c_char = toupper(c_char); - if (c_char != 0) { + if (c_char != '\0') { if (c_char == ascii_text[c_match]) { - c_match++; + c_match += 1; if (c_match == textlen) { result = MR_MATCHED; cf->search_pos = i; /* Save the position of the last character for highlighting the field. */ break; } - } else + } + else { + g_assert(i>=c_match); + i -= c_match; c_match = 0; + } } + i += 1; } return result; } @@ -3036,21 +3042,28 @@ match_ascii(capture_file *cf, frame_data *fdata, void *criterion) result = MR_NOTMATCHED; buf_len = fdata->pkt_len; - for (i = 0; i < buf_len; i++) { + i = 0; + while (i < buf_len) { c_char = cf->pd[i]; if (cf->case_type) c_char = toupper(c_char); if (c_char == ascii_text[c_match]) { - c_match++; + c_match += 1; if (c_match == textlen) { result = MR_MATCHED; cf->search_pos = i; /* Save the position of the last character for highlighting the field. */ break; } - } else + } + else { + g_assert(i>=c_match); + i -= c_match; c_match = 0; + } + i += 1; } + return result; } @@ -3074,21 +3087,27 @@ match_unicode(capture_file *cf, frame_data *fdata, void *criterion) result = MR_NOTMATCHED; buf_len = fdata->pkt_len; - for (i = 0; i < buf_len; i++) { + i = 0; + while (i < buf_len) { c_char = cf->pd[i]; if (cf->case_type) c_char = toupper(c_char); if (c_char == ascii_text[c_match]) { - c_match++; - i++; + c_match += 1; if (c_match == textlen) { result = MR_MATCHED; cf->search_pos = i; /* Save the position of the last character for highlighting the field. */ break; } - } else + i += 1; + } + else { + g_assert(i>=(c_match*2)); + i -= c_match*2; c_match = 0; + } + i += 1; } return result; } @@ -3112,17 +3131,23 @@ match_binary(capture_file *cf, frame_data *fdata, void *criterion) result = MR_NOTMATCHED; buf_len = fdata->pkt_len; - for (i = 0; i < buf_len; i++) { + i = 0; + while (i < buf_len) { if (cf->pd[i] == binary_data[c_match]) { - c_match++; + c_match += 1; if (c_match == datalen) { result = MR_MATCHED; cf->search_pos = i; /* Save the position of the last character for highlighting the field. */ break; } - } else + } + else { + g_assert(i>=c_match); + i -= c_match; c_match = 0; + } + i += 1; } return result; } |