Commit d7bf8ec0 authored by Pascal Quantin's avatar Pascal Quantin

proto.c: do not perform bound checks in proto_tree_add_text(_valist)_internal if tvb is NULL

As seen in bug 12676, some buggy dissectors do not systematically provide a tvb when calling proto_tree_add_XXX functions.
On stable branch, let's deactivate the bound checks in that case.

Bug: 12676
Change-Id: Ia3cf0b0972c127f34feca2e097e0ec1fd1753b23
Reviewed-on: https://code.wireshark.org/review/16752
Petri-Dish: Pascal Quantin <[email protected]>
Tested-by: default avatarPetri Dish Buildbot <[email protected]>
Reviewed-by: Pascal Quantin's avatarPascal Quantin <[email protected]>
(cherry picked from commit 8c7ab5f2)
Reviewed-on: https://code.wireshark.org/review/17025
parent bdf018e1
......@@ -1135,13 +1135,15 @@ proto_tree_add_text(proto_tree *tree, tvbuff_t *tvb, gint start, gint length,
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;
if (tvb) {
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);
}
tvb_ensure_bytes_exist(tvb, start, length);
TRY_TO_FAKE_THIS_ITEM(tree, hf_text_only, hfinfo);
......@@ -1164,13 +1166,15 @@ proto_tree_add_text_valist(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;
if (tvb) {
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);
}
tvb_ensure_bytes_exist(tvb, start, length);
TRY_TO_FAKE_THIS_ITEM(tree, hf_text_only, hfinfo);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment