aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Maynard <Christopher.Maynard@GTECH.COM>2013-10-12 18:13:26 +0000
committerChris Maynard <Christopher.Maynard@GTECH.COM>2013-10-12 18:13:26 +0000
commitb610734a12a4fbdfddfa777c7444d6896b94093f (patch)
tree03fb8387d3ef922238dce52242344ba564ef67d9
parent65accd3c18b449f6f06758e2f80c50eabfd384dd (diff)
If the offset is out of bounds, have tvb_length_remaining() and tvb_reported_length_remaining() return 0 instead of -1. This should provide a better long-term fix for bugs/problems such as seen in https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9263. In the long-run, if we like this behavior, we can change the return value to a guint as well. Let's let it simmer for awhile first ...
svn path=/trunk/; revision=52571
-rw-r--r--epan/tvbuff.c6
-rw-r--r--epan/tvbuff.h7
2 files changed, 6 insertions, 7 deletions
diff --git a/epan/tvbuff.c b/epan/tvbuff.c
index 85953b3013..0e2888d248 100644
--- a/epan/tvbuff.c
+++ b/epan/tvbuff.c
@@ -427,7 +427,7 @@ tvb_length_remaining(const tvbuff_t *tvb, const gint offset)
exception = compute_offset_and_remaining(tvb, offset, &abs_offset, &rem_length);
if (exception)
- return -1;
+ return 0;
return rem_length;
}
@@ -545,12 +545,12 @@ tvb_reported_length_remaining(const tvbuff_t *tvb, const gint offset)
exception = compute_offset(tvb, offset, &abs_offset);
if (exception)
- return -1;
+ return 0;
if (tvb->reported_length >= abs_offset)
return tvb->reported_length - abs_offset;
else
- return -1;
+ return 0;
}
/* Set the reported length of a tvbuff to a given value; used for protocols
diff --git a/epan/tvbuff.h b/epan/tvbuff.h
index 0646fcef38..7fef12da6b 100644
--- a/epan/tvbuff.h
+++ b/epan/tvbuff.h
@@ -221,8 +221,8 @@ WS_DLL_PUBLIC void tvb_composite_finalize(tvbuff_t* tvb);
WS_DLL_PUBLIC guint tvb_length(const tvbuff_t*);
/** Computes bytes to end of buffer, from offset (which can be negative,
- * to indicate bytes from end of buffer). Function returns -1 to
- * indicate that offset is out of bounds. No exception is thrown. */
+ * to indicate bytes from end of buffer). Function returns 0 if offset is out
+ * of bounds. No exception is thrown. */
WS_DLL_PUBLIC gint tvb_length_remaining(const tvbuff_t*, const gint offset);
/** Same as above, but throws an exception if the offset is out of bounds. */
@@ -244,8 +244,7 @@ WS_DLL_PUBLIC guint tvb_reported_length(const tvbuff_t*);
/** Computes bytes of reported packet data to end of buffer, from offset
* (which can be negative, to indicate bytes from end of buffer). Function
- * returns -1 to indicate that offset is out of bounds. No exception is
- * thrown. */
+ * returns 0 if offset is out of bounds. No exception is thrown. */
WS_DLL_PUBLIC gint tvb_reported_length_remaining(const tvbuff_t *tvb, const gint offset);
/** Set the reported length of a tvbuff to a given value; used for protocols