proto.c: do not set an item length longer that the remaining tvb length
Ping-Bug: 14128 Change-Id: Iae5cb2f85d5d2fa3f2b6051aa57390a3f73d724a Reviewed-on: https://code.wireshark.org/review/24087 Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com> Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Michael Mann <mmann78@netscape.net>
This commit is contained in:
parent
ed20250c13
commit
e82adfba74
12
epan/proto.c
12
epan/proto.c
|
@ -6219,16 +6219,22 @@ proto_item_prepend_text(proto_item *pi, const char *format, ...)
|
|||
static void
|
||||
finfo_set_len(field_info *fi, const gint length)
|
||||
{
|
||||
gint length_remaining;
|
||||
|
||||
DISSECTOR_ASSERT(length >= 0);
|
||||
fi->length = length;
|
||||
length_remaining = tvb_captured_length_remaining(fi->ds_tvb, fi->start);
|
||||
if (length > length_remaining)
|
||||
fi->length = length_remaining;
|
||||
else
|
||||
fi->length = length;
|
||||
|
||||
/*
|
||||
* You cannot just make the "len" field of a GByteArray
|
||||
* larger, if there's no data to back that length;
|
||||
* you can only make it smaller.
|
||||
*/
|
||||
if (fi->value.ftype->ftype == FT_BYTES && length <= (gint)fi->value.value.bytes->len)
|
||||
fi->value.value.bytes->len = length;
|
||||
if (fi->value.ftype->ftype == FT_BYTES && fi->length <= (gint)fi->value.value.bytes->len)
|
||||
fi->value.value.bytes->len = fi->length;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Reference in New Issue