aboutsummaryrefslogtreecommitdiffstats
path: root/epan/tvbuff_real.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_real.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_real.c')
-rw-r--r--epan/tvbuff_real.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/epan/tvbuff_real.c b/epan/tvbuff_real.c
index 0d86edfaaa..0d82e0a98d 100644
--- a/epan/tvbuff_real.c
+++ b/epan/tvbuff_real.c
@@ -64,10 +64,11 @@ tvb_new_real_data(const guint8* data, const guint length, const gint reported_le
tvb = tvb_new(&tvb_real_ops);
- tvb->real_data = data;
- tvb->length = length;
- tvb->reported_length = reported_length;
- tvb->initialized = TRUE;
+ tvb->real_data = data;
+ tvb->length = length;
+ tvb->reported_length = reported_length;
+ tvb->contained_length = reported_length;
+ tvb->initialized = TRUE;
/*
* This is the top-level real tvbuff for this data source,