aboutsummaryrefslogtreecommitdiffstats
path: root/epan/tvbuff-int.h
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-int.h
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-int.h')
-rw-r--r--epan/tvbuff-int.h20
1 files changed, 19 insertions, 1 deletions
diff --git a/epan/tvbuff-int.h b/epan/tvbuff-int.h
index 6a5c1d4490..17128abdf7 100644
--- a/epan/tvbuff-int.h
+++ b/epan/tvbuff-int.h
@@ -55,7 +55,9 @@ struct tvbuff {
* file. This is the length of virtual buffer (and/or
* real_data). It may be less than the reported
* length if this is from a packet that was cut short
- * by the capture process. */
+ * by the capture process.
+ *
+ * This must never be > reported_length or contained_length. */
guint length;
/** Amount of data that was reported as being in
@@ -64,6 +66,22 @@ struct tvbuff {
* amount of data that's available. */
guint reported_length;
+ /** If this was extracted from a parent tvbuff,
+ * this is the amount of extracted data that
+ * was reported as being in the parent tvbuff;
+ * if this represents a blob of data in that
+ * tvbuff that has a length specified by data
+ * in that tvbuff, it might be greater than
+ * the amount of data that was actually there
+ * to extract, so it could be greater than
+ * reported_length.
+ *
+ * If this wasn't extracted from a parent tvbuff,
+ * this is the same as reported_length.
+ *
+ * This must never be > reported_length. */
+ guint contained_length;
+
/* Offset from beginning of first "real" tvbuff. */
gint raw_offset;
};