diff options
author | Evan Huus <eapache@gmail.com> | 2014-04-23 11:50:24 -0400 |
---|---|---|
committer | Evan Huus <eapache@gmail.com> | 2014-04-23 15:57:13 +0000 |
commit | fe195c0c978b4b92dc5a77daa6449a7f1314243d (patch) | |
tree | c975dc7d3eba3aeea979122888dd08e90df5ecb5 /epan/tvbuff.c | |
parent | be13690c3ce269f215040f8d91baf374d05100e8 (diff) |
Don't throw for offset at end of TVB with len -1.
g867a1827e7dc88896ee27a107eb35c4b3973d270 introduced a change to cleanup/fix
handling of bounds checks for -1 length fields, but it ended up guaranteeing a
throw for 0-length tvbs, which isn't good; we ought to be able to add 0-length
FT_PROTOCOL items at the very least.
Better names for the function than _cheat are welcome, but I want to shut up the
buildbot.
Change-Id: I24610f947d03dac32766e2a0ffa0ff7bcc74c3e8
Reviewed-on: https://code.wireshark.org/review/1303
Reviewed-by: Evan Huus <eapache@gmail.com>
Diffstat (limited to 'epan/tvbuff.c')
-rw-r--r-- | epan/tvbuff.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/epan/tvbuff.c b/epan/tvbuff.c index 598e90dd5a..04a8cef71e 100644 --- a/epan/tvbuff.c +++ b/epan/tvbuff.c @@ -450,6 +450,24 @@ tvb_captured_length_remaining(const tvbuff_t *tvb, const gint offset) return rem_length; } +/* Just like tvb_ensure_captured_length_remaining except it doesn't have to + * guarantee that at least one byte is available, it simply guarantees that the + * offset exists (so a 0 offset in a 0-length tvb won't throw) */ +guint +tvb_ensure_captured_length_remaining_cheat(const tvbuff_t *tvb, const gint offset) +{ + guint abs_offset, rem_length; + int exception; + + DISSECTOR_ASSERT(tvb && tvb->initialized); + + exception = compute_offset_and_remaining(tvb, offset, &abs_offset, &rem_length); + if (exception) + THROW(exception); + + return rem_length; +} + guint tvb_ensure_captured_length_remaining(const tvbuff_t *tvb, const gint offset) { |