diff options
author | Pascal Quantin <pascal.quantin@gmail.com> | 2017-08-02 21:32:30 +0200 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2017-08-04 05:55:34 +0000 |
commit | ce7b994383a8089e7c05b7c88132fe78de9a1be9 (patch) | |
tree | 41a7c65495c03b445cc10c4aa633072ee1a4e3f1 /epan/proto.c | |
parent | 733c19a0720035c1aa19d79f765d72b085d58bdd (diff) |
proto.c: fix use of proto_tree_add_text(_valist)_internal() with length = -1
When using a length of -1, use the tvb remaining length instead of 0.
Change-Id: I569e9c9f57531914a3b613c3a6a9bff076fba362
Reviewed-on: https://code.wireshark.org/review/22931
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/proto.c')
-rw-r--r-- | epan/proto.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/epan/proto.c b/epan/proto.c index a15792eb36..f57e4873f5 100644 --- a/epan/proto.c +++ b/epan/proto.c @@ -1241,12 +1241,10 @@ proto_tree_add_text_internal(proto_tree *tree, tvbuff_t *tvb, gint start, gint l header_field_info *hfinfo; if (length == -1) { - /* If we're fetching until the end of the TVB, only validate - * that the offset is within range. - */ - length = 0; + length = tvb_captured_length(tvb) ? tvb_ensure_captured_length_remaining(tvb, start) : 0; + } else { + tvb_ensure_bytes_exist(tvb, start, length); } - tvb_ensure_bytes_exist(tvb, start, length); CHECK_FOR_NULL_TREE(tree); @@ -1272,12 +1270,10 @@ proto_tree_add_text_valist_internal(proto_tree *tree, tvbuff_t *tvb, gint start, header_field_info *hfinfo; if (length == -1) { - /* If we're fetching until the end of the TVB, only validate - * that the offset is within range. - */ - length = 0; + length = tvb_captured_length(tvb) ? tvb_ensure_captured_length_remaining(tvb, start) : 0; + } else { + tvb_ensure_bytes_exist(tvb, start, length); } - tvb_ensure_bytes_exist(tvb, start, length); CHECK_FOR_NULL_TREE(tree); |