aboutsummaryrefslogtreecommitdiffstats
path: root/epan/tvbuff.c
diff options
context:
space:
mode:
authorGuy Harris <gharris@sonic.net>2022-09-03 03:24:33 -0700
committerGuy Harris <gharris@sonic.net>2022-09-03 21:04:55 +0000
commit022dfd56f3ff0d3d99b3e1aa0680d2b0440e5332 (patch)
treeff09a5aeb23ebbc06ff5f611643f8a88e76c1ea5 /epan/tvbuff.c
parente76ebbdeccd1a9fc039fa450b34222dd42668c54 (diff)
Fix bogus tvbuffs to make sure reported length >= captured length.
A reported length less than a captured length is bogus, as you cannot capture more data than there is in a packet. Fixes #18313.
Diffstat (limited to 'epan/tvbuff.c')
-rw-r--r--epan/tvbuff.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/epan/tvbuff.c b/epan/tvbuff.c
index 5d336a9e78..99378f1c58 100644
--- a/epan/tvbuff.c
+++ b/epan/tvbuff.c
@@ -806,6 +806,21 @@ tvb_set_reported_length(tvbuff_t *tvb, const guint reported_length)
tvb->contained_length = reported_length;
}
+/* Repair a tvbuff where the captured length is greater than the
+ * reported length; such a tvbuff makes no sense, as it's impossible
+ * to capture more data than is in the packet.
+ */
+void
+tvb_fix_reported_length(tvbuff_t *tvb)
+{
+ DISSECTOR_ASSERT(tvb && tvb->initialized);
+ DISSECTOR_ASSERT(tvb->reported_length < tvb->length);
+
+ tvb->reported_length = tvb->length;
+ if (tvb->contained_length < tvb->length)
+ tvb->contained_length = tvb->length;
+}
+
guint
tvb_offset_from_real_beginning_counter(const tvbuff_t *tvb, const guint counter)
{