aboutsummaryrefslogtreecommitdiffstats
path: root/epan/tvbuff_composite.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2018-04-19 20:18:10 -0700
committerGuy Harris <guy@alum.mit.edu>2018-04-20 03:18:47 +0000
commit0a130c5756eda79cbb55f1d38824fbaf9d1abc68 (patch)
treefb3188f1965219c227e82fb5fcb7cc5307a5e1fc /epan/tvbuff_composite.c
parent9011a25afc598bfb5d46be92b2ef112cd1b17594 (diff)
Handle subset tvbuffs where the length goes past the end of the parent.
Add a "contained length" to tvbuffs. For non-subset tvbuffs, that's the same as the reported length. For a subset tvbuff, that's the amount of the reported data that was actually present in the "contained data" of the parent tvbuff. This is unaffected by the *captured* length of any tvbuff; that differs from the contained length only if the capture was cut short by a snapshot length. If a reference is within the reported data, but not within the contained data, a ContainedBoundsError exception is thrown. This exception represents a protocol error, rather than a reference past the captured data in the packet; we treat it as such. Change-Id: Ide87f81238eaeb89b3093f54a87bf7f715485af5 Reviewed-on: https://code.wireshark.org/review/27039 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'epan/tvbuff_composite.c')
-rw-r--r--epan/tvbuff_composite.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/epan/tvbuff_composite.c b/epan/tvbuff_composite.c
index 5832477f81..f77aace029 100644
--- a/epan/tvbuff_composite.c
+++ b/epan/tvbuff_composite.c
@@ -259,6 +259,7 @@ tvb_composite_finalize(tvbuff_t *tvb)
DISSECTOR_ASSERT(tvb->ops == &tvb_composite_ops);
DISSECTOR_ASSERT(tvb->length == 0);
DISSECTOR_ASSERT(tvb->reported_length == 0);
+ DISSECTOR_ASSERT(tvb->contained_length == 0);
composite = &composite_tvb->composite;
num_members = g_slist_length(composite->tvbs);
@@ -278,6 +279,7 @@ tvb_composite_finalize(tvbuff_t *tvb)
composite->start_offsets[i] = tvb->length;
tvb->length += member_tvb->length;
tvb->reported_length += member_tvb->reported_length;
+ tvb->contained_length += member_tvb->contained_length;
composite->end_offsets[i] = tvb->length - 1;
i++;
}