summaryrefslogtreecommitdiff
path: root/epan/proto.c
diff options
context:
space:
mode:
authorPascal Quantin <pascal.quantin@gmail.com>2016-07-25 11:19:05 +0200
committerAnders Broman <a.broman58@gmail.com>2016-07-26 03:52:39 +0000
commit56706427f53cc64793870bf072c2c06248ae88f3 (patch)
tree2b336dca29bff87a1acd6fac55ff8bb0070bbeb2 /epan/proto.c
parent896751e013a63733702ab2c247ea8ff9db0b0332 (diff)
downloadwireshark-56706427f53cc64793870bf072c2c06248ae88f3.tar.gz
proto.c: add bounds check to proto_tree_add_text(_valist)_internal
Bug: 12659 Change-Id: I44cb3ce8e647ae2816d5ffa95435068c435a1e5c Reviewed-on: https://code.wireshark.org/review/16648 Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com> Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/proto.c')
-rw-r--r--epan/proto.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/epan/proto.c b/epan/proto.c
index f675dfc37d..963da1e653 100644
--- a/epan/proto.c
+++ b/epan/proto.c
@@ -1184,6 +1184,14 @@ proto_tree_add_text_internal(proto_tree *tree, tvbuff_t *tvb, gint start, gint l
va_list ap;
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;
+ }
+ tvb_ensure_bytes_exist(tvb, start, length);
+
CHECK_FOR_NULL_TREE(tree);
TRY_TO_FAKE_THIS_ITEM(tree, hf_text_only, hfinfo);
@@ -1207,6 +1215,14 @@ proto_tree_add_text_valist_internal(proto_tree *tree, tvbuff_t *tvb, gint start,
proto_item *pi;
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;
+ }
+ tvb_ensure_bytes_exist(tvb, start, length);
+
CHECK_FOR_NULL_TREE(tree);
TRY_TO_FAKE_THIS_ITEM(tree, hf_text_only, hfinfo);