summaryrefslogtreecommitdiff
path: root/epan/tvbuff.c
diff options
context:
space:
mode:
authorGilbert Ramirez <gram@alumni.rice.edu>2002-02-01 04:34:17 +0000
committerGilbert Ramirez <gram@alumni.rice.edu>2002-02-01 04:34:17 +0000
commitbd4a9c13eb557b93f3e80f2c66226cbfe6082a82 (patch)
tree65878dfe4ebb3e9f077e408a572bc9227a524ded /epan/tvbuff.c
parenta9f7ef50586b671e402cf24f7175d07e18e0f180 (diff)
downloadwireshark-bd4a9c13eb557b93f3e80f2c66226cbfe6082a82.tar.gz
Provide tvb_ensure_length_remaining(), which is like
tvb_length_remaining() except that it throws BoundsError if 'offset' is out-of-bounds. Allow a length argument of -1 for FT_STRING and FT_BYTES fields in proto_tree_add_item(). Change some dissectors to either use -1 for the length argument in calls to proto_tree_add_item(), or call tvb_ensure_length_remaining() instead of tvb_length_remaining(), or to check the return-value of tvb_length_remaining(). Changes to more dissectors are necessary, but will follow later. svn path=/trunk/; revision=4656
Diffstat (limited to 'epan/tvbuff.c')
-rw-r--r--epan/tvbuff.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/epan/tvbuff.c b/epan/tvbuff.c
index d24643e243..163a4bd90d 100644
--- a/epan/tvbuff.c
+++ b/epan/tvbuff.c
@@ -9,7 +9,7 @@
* the data of a backing tvbuff, or can be a composite of
* other tvbuffs.
*
- * $Id: tvbuff.c,v 1.27 2002/01/04 06:45:14 gram Exp $
+ * $Id: tvbuff.c,v 1.28 2002/02/01 04:34:17 gram Exp $
*
* Copyright (c) 2000 by Gilbert Ramirez <gram@alumni.rice.edu>
*
@@ -606,6 +606,22 @@ tvb_length_remaining(tvbuff_t *tvb, gint offset)
}
}
+gint
+tvb_ensure_length_remaining(tvbuff_t *tvb, gint offset)
+{
+ gint retval;
+
+ retval = tvb_length_remaining(tvb, offset);
+
+ if (retval == -1) {
+ THROW(ReportedBoundsError);
+ }
+ else {
+ return retval;
+ }
+}
+
+
/* Validates that 'length' bytes are available starting from