aboutsummaryrefslogtreecommitdiffstats
path: root/epan/tvbuff.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2003-12-23 21:22:00 +0000
committerGuy Harris <guy@alum.mit.edu>2003-12-23 21:22:00 +0000
commit821baa3d48ae58afb1da20e5f4f7e0699c1520b6 (patch)
tree2766be43df63431fc4fe45f4591cd8a8b16f57fd /epan/tvbuff.c
parent8afbfc0c6097596b50d41c849210337bd9c41ccc (diff)
Have "tvb_ensure_length_remaining()" throw the appropriate exception if
there's no data remaining - its callers largely depend on it doing so. That means that the BEEP dissector doesn't have to check for it returning 0. svn path=/trunk/; revision=9433
Diffstat (limited to 'epan/tvbuff.c')
-rw-r--r--epan/tvbuff.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/epan/tvbuff.c b/epan/tvbuff.c
index 35846a26c9..f0e2ed3596 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.54 2003/12/03 10:14:34 sahlberg Exp $
+ * $Id: tvbuff.c,v 1.55 2003/12/23 21:22:00 guy Exp $
*
* Copyright (c) 2000 by Gilbert Ramirez <gram@alumni.rice.edu>
*
@@ -590,6 +590,17 @@ tvb_ensure_length_remaining(tvbuff_t *tvb, gint offset)
if (!compute_offset_length(tvb, offset, -1, &abs_offset, &abs_length, &exception)) {
THROW(exception);
}
+ if (abs_length == 0) {
+ /*
+ * This routine ensures there's at least one byte available.
+ * There aren't any bytes available, so throw the appropriate
+ * exception.
+ */
+ if (abs_offset > tvb->reported_length)
+ THROW(ReportedBoundsError);
+ else
+ THROW(BoundsError);
+ }
return abs_length;
}