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
This commit is contained in:
parent
cf308a6cc0
commit
1f96f14083
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue