diff options
Diffstat (limited to 'epan/tvbuff.c')
-rw-r--r-- | epan/tvbuff.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/epan/tvbuff.c b/epan/tvbuff.c index b154791a4d..d737fad84f 100644 --- a/epan/tvbuff.c +++ b/epan/tvbuff.c @@ -539,9 +539,6 @@ tvb_ensure_captured_length_remaining(const tvbuff_t *tvb, const gint offset) return rem_length; } - - - /* Validates that 'length' bytes are available starting from * offset (pos/neg). Does not throw an exception. */ gboolean @@ -713,6 +710,24 @@ tvb_reported_length_remaining(const tvbuff_t *tvb, const gint offset) return 0; } +guint +tvb_ensure_reported_length_remaining(const tvbuff_t *tvb, const gint offset) +{ + guint abs_offset = 0; + int exception; + + DISSECTOR_ASSERT(tvb && tvb->initialized); + + exception = compute_offset(tvb, offset, &abs_offset); + if (exception) + THROW(exception); + + if (tvb->reported_length >= abs_offset) + return tvb->reported_length - abs_offset; + else + THROW(ReportedBoundsError); +} + /* Set the reported length of a tvbuff to a given value; used for protocols * whose headers contain an explicit length and where the calling * dissector's payload may include padding as well as the packet for |