diff options
author | Pascal Quantin <pascal.quantin@gmail.com> | 2017-10-26 22:47:19 +0200 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2017-10-26 23:37:51 +0000 |
commit | e82adfba74957948781c0518088bd16365740c18 (patch) | |
tree | 377d4321dea79d0b4fd9e628e70c9a4bdc65bb27 /epan | |
parent | ed20250c132c5855dcb0df991c31ab4de6b47a61 (diff) |
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>
Diffstat (limited to 'epan')
-rw-r--r-- | epan/proto.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/epan/proto.c b/epan/proto.c index 5cea478e00..a4b66b482f 100644 --- a/epan/proto.c +++ b/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 |