aboutsummaryrefslogtreecommitdiffstats
path: root/epan/proto.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2016-11-19 21:59:28 -0800
committerGuy Harris <guy@alum.mit.edu>2016-11-20 06:00:12 +0000
commit548bf927d427723ad22e8e23186a63a63e4abf43 (patch)
tree09c501e32b60eca53f26b6f2c826b6a02d7742b8 /epan/proto.c
parent6bd322223d3f13612a449cbba20ce36e9da30ebb (diff)
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 <guy@alum.mit.edu>
Diffstat (limited to 'epan/proto.c')
-rw-r--r--epan/proto.c12
1 files changed, 11 insertions, 1 deletions
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