diff options
author | Guy Harris <guy@alum.mit.edu> | 2000-11-30 06:11:32 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2000-11-30 06:11:32 +0000 |
commit | 50f6a061a777e7cdd5df55f8d6495214a4fc07a4 (patch) | |
tree | 2690dbf094ded28100c3e3a04e32658f1c1408ad /epan | |
parent | a0729a25dd4daa0b2527100d1ce792879fd28760 (diff) |
In "tvb_find_guint8()" and "tvb_pbrk_guint8()", correctly set the limit
of the search if the caller-supplied limit goes past the end of the
tvbuff - the limit should just be what remains in the tvbuff after the
specified starting offset.
In "tvb_find_line_end_unquoted()", after searching for the next
interesting character, check the value we got back from that search, in
"char_offset", not whatever happens to be in "cur_offset", to see if we
found a character.
svn path=/trunk/; revision=2719
Diffstat (limited to 'epan')
-rw-r--r-- | epan/tvbuff.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/epan/tvbuff.c b/epan/tvbuff.c index 2d18b9c799..f2a3566f47 100644 --- a/epan/tvbuff.c +++ b/epan/tvbuff.c @@ -9,7 +9,7 @@ * the data of a backing tvbuff, or can be a composite of * other tvbuffs. * - * $Id: tvbuff.c,v 1.11 2000/11/30 03:24:16 gram Exp $ + * $Id: tvbuff.c,v 1.12 2000/11/30 06:11:32 guy Exp $ * * Copyright (c) 2000 by Gilbert Ramirez <gram@xiexie.org> * @@ -1030,12 +1030,17 @@ tvb_find_guint8(tvbuff_t *tvb, gint offset, guint maxlength, guint8 needle) /* Only search to end of tvbuff, w/o throwing exception. */ tvbufflen = tvb_length_remaining(tvb, abs_offset); if (maxlength == -1) { + /* No maximum length specified; search to end of tvbuff. */ limit = tvbufflen; } else if (tvbufflen < maxlength) { - limit = maxlength - (tvb_length(tvb) - abs_offset); + /* Maximum length goes past end of tvbuff; search to end + of tvbuff. */ + limit = tvbufflen; } else { + /* Maximum length doesn't go past end of tvbuff; search + to that value. */ limit = maxlength; } @@ -1088,12 +1093,17 @@ tvb_pbrk_guint8(tvbuff_t *tvb, gint offset, guint maxlength, guint8 *needles) /* Only search to end of tvbuff, w/o throwing exception. */ tvbufflen = tvb_length_remaining(tvb, abs_offset); if (maxlength == -1) { + /* No maximum length specified; search to end of tvbuff. */ limit = tvbufflen; } else if (tvbufflen < maxlength) { - limit = maxlength - (tvb_length(tvb) - abs_offset); + /* Maximum length goes past end of tvbuff; search to end + of tvbuff. */ + limit = tvbufflen; } else { + /* Maximum length doesn't go past end of tvbuff; search + to that value. */ limit = maxlength; } @@ -1411,7 +1421,7 @@ tvb_find_line_end_unquoted(tvbuff_t *tvb, gint offset, int len, char_offset = tvb_pbrk_guint8(tvb, cur_offset, len, "\r\n\""); } - if (cur_offset == -1) { + if (char_offset == -1) { /* * Not found - line is presumably continued in * next packet. |