diff options
author | Guy Harris <guy@alum.mit.edu> | 2009-04-03 17:04:45 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2009-04-03 17:04:45 +0000 |
commit | 1f96f140836e1d7ab85739ba94b0a3bf0bdd5bd1 (patch) | |
tree | 0f4b48280ea67a983f7dab435de90b8422e3b8eb | |
parent | cf308a6cc0bce42f7e6993f598a0286c4b8a8dce (diff) | |
download | wireshark-1f96f140836e1d7ab85739ba94b0a3bf0bdd5bd1.tar.gz |
Don't support a length of -1 meaning "to the end of the tvbuff" in
tvb_memcpy(); I changed the one tvb_memcpy() call that was explicitly
depending on that not to do so. This is a small step towards getting
rid of the "-1 means to end of tvbuff" convention, support for which
requires us to do a bunch of extra checks where, for example, a protocol
has a 32-bit unsigned length field; it also gets rid of a warning about
comparing an unsigned value with a signed value.
svn path=/trunk/; revision=27946
-rw-r--r-- | epan/tvbuff.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/epan/tvbuff.c b/epan/tvbuff.c index 9d0a573a38..a390de74fb 100644 --- a/epan/tvbuff.c +++ b/epan/tvbuff.c @@ -1011,7 +1011,18 @@ tvb_memcpy(tvbuff_t *tvb, void* target, gint offset, size_t length) { guint abs_offset, abs_length; - DISSECTOR_ASSERT(length >= -1); + /* + * XXX - we should eliminate the "length = -1 means 'to the end + * of the tvbuff'" convention, and use other means to achieve + * that; this would let us eliminate a bunch of checks for + * negative lengths in cases where the protocol has a 32-bit + * length field. + * + * Allowing -1 but throwing an assertion on other negative + * lengths is a bit more work with the length being a size_t; + * instead, we check for a length <= 2^31-1. + */ + DISSECTOR_ASSERT(length <= 0x7FFFFFFF); check_offset_length(tvb, offset, (gint) length, &abs_offset, &abs_length); if (tvb->real_data) { |