aboutsummaryrefslogtreecommitdiffstats
path: root/frame_tvbuff.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 /frame_tvbuff.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 'frame_tvbuff.c')
-rw-r--r--frame_tvbuff.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/frame_tvbuff.c b/frame_tvbuff.c
index 0707b46ac5..e2aaf1826e 100644
--- a/frame_tvbuff.c
+++ b/frame_tvbuff.c
@@ -190,10 +190,11 @@ frame_tvbuff_new(const struct packet_provider_data *prov, const frame_data *fd,
* tvb_new_real_data() now there's no one
*/
- tvb->real_data = buf;
- tvb->length = fd->cap_len;
- tvb->reported_length = fd->pkt_len > G_MAXINT ? G_MAXINT : fd->pkt_len;
- tvb->initialized = TRUE;
+ tvb->real_data = buf;
+ tvb->length = fd->cap_len;
+ tvb->reported_length = fd->pkt_len > G_MAXINT ? G_MAXINT : fd->pkt_len;
+ tvb->contained_length = tvb->reported_length;
+ tvb->initialized = TRUE;
/*
* This is the top-level real tvbuff for this data source,
@@ -240,10 +241,11 @@ frame_clone(tvbuff_t *tvb, guint abs_offset, guint abs_length)
cloned_tvb = tvb_new(&tvb_frame_ops);
/* data will be read when needed */
- cloned_tvb->real_data = NULL;
- cloned_tvb->length = abs_length;
- cloned_tvb->reported_length = abs_length; /* XXX? */
- cloned_tvb->initialized = TRUE;
+ cloned_tvb->real_data = NULL;
+ cloned_tvb->length = abs_length;
+ cloned_tvb->reported_length = abs_length; /* XXX? */
+ cloned_tvb->contained_length = cloned_tvb->reported_length;
+ cloned_tvb->initialized = TRUE;
/*
* This is the top-level real tvbuff for this data source,
@@ -293,10 +295,11 @@ file_tvbuff_new(const struct packet_provider_data *prov, const frame_data *fd,
* tvb_new_real_data() now there's no one
*/
- tvb->real_data = buf;
- tvb->length = fd->cap_len;
- tvb->reported_length = fd->pkt_len > G_MAXINT ? G_MAXINT : fd->pkt_len;
- tvb->initialized = TRUE;
+ tvb->real_data = buf;
+ tvb->length = fd->cap_len;
+ tvb->reported_length = fd->pkt_len > G_MAXINT ? G_MAXINT : fd->pkt_len;
+ tvb->contained_length = tvb->reported_length;
+ tvb->initialized = TRUE;
/*
* This is the top-level real tvbuff for this data source,