epan: Handle subset tvbuffs with non-zero offets and length -1
According to tvbuff.h, tvb_new_subset_length() with length -1 should behave like tvb_new_subset_remaining(). That means that the reported length should subtract off the offset into the original tvb.
This commit is contained in:
parent
58907c0723
commit
ccf720d95d
|
@ -211,6 +211,16 @@ tvb_new_subset_length(tvbuff_t *backing, const gint backing_offset, const gint r
|
|||
&subset_tvb_offset,
|
||||
&subset_tvb_length);
|
||||
|
||||
/*
|
||||
* If the requested reported length is "to the end of the buffer",
|
||||
* subtract the offset from the total length. We do this now, because
|
||||
* the user might have passed in a negative offset.
|
||||
*/
|
||||
if (reported_length == -1) {
|
||||
THROW_ON(backing->reported_length < subset_tvb_offset, ReportedBoundsError);
|
||||
actual_reported_length -= subset_tvb_offset;
|
||||
}
|
||||
|
||||
tvb = tvb_new_with_subset(backing, (guint)actual_reported_length,
|
||||
subset_tvb_offset, subset_tvb_length);
|
||||
|
||||
|
|
Loading…
Reference in New Issue