From 548bf927d427723ad22e8e23186a63a63e4abf43 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Sat, 19 Nov 2016 21:59:28 -0800 Subject: proto_item_set_end() should set the FT_BYTES value length as well. Change-Id: I33459aabf059e1dc746e7e5f9d5ca28095e056f4 Reviewed-on: https://code.wireshark.org/review/18880 Reviewed-by: Guy Harris --- epan/proto.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'epan/proto.c') diff --git a/epan/proto.c b/epan/proto.c index 606ccc6c40..8ddb971298 100644 --- a/epan/proto.c +++ b/epan/proto.c @@ -5481,6 +5481,7 @@ void proto_item_set_end(proto_item *pi, tvbuff_t *tvb, gint end) { field_info *fi; + gint length; TRY_TO_FAKE_THIS_REPR_VOID(pi); @@ -5490,7 +5491,16 @@ proto_item_set_end(proto_item *pi, tvbuff_t *tvb, gint end) end += tvb_raw_offset(tvb); DISSECTOR_ASSERT(end >= fi->start); - fi->length = end - fi->start; + length = end - fi->start; + 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; } int -- cgit v1.2.3