summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Mitz <mitza@ociweb.com>2017-01-23 14:15:42 -0600
committerAnders Broman <a.broman58@gmail.com>2017-01-24 14:00:38 +0000
commit4e2b2d4292243f13e5fe1638a12704d43dbd07df (patch)
treed9795f5b67b7e46a289125a791b0eb594e3275a3
parent87f24a78e62431bbe0e22c1e7f42e1e94c1d79b0 (diff)
downloadwireshark-4e2b2d4292243f13e5fe1638a12704d43dbd07df.tar.gz
RTPS: avoid errors when encountering empty sequences of strings
Change-Id: Ida9d2e6d632104ec3c6594f5ec500fec49a971a4 Reviewed-on: https://code.wireshark.org/review/19754 Reviewed-by: Michael Mann <mmann78@netscape.net> Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
-rw-r--r--epan/dissectors/packet-rtps.c17
-rw-r--r--epan/dissectors/packet-rtps.h2
2 files changed, 13 insertions, 6 deletions
diff --git a/epan/dissectors/packet-rtps.c b/epan/dissectors/packet-rtps.c
index afa9582424..c3a5a453c7 100644
--- a/epan/dissectors/packet-rtps.c
+++ b/epan/dissectors/packet-rtps.c
@@ -2344,18 +2344,24 @@ static void rtps_util_add_product_version(proto_tree *tree, tvbuff_t *tvb, gint
* Returns the new updated offset
*/
gint rtps_util_add_seq_string(proto_tree *tree, tvbuff_t *tvb, gint offset,
- const guint encoding, int param_length, int hf_numstring,
+ const guint encoding, int hf_numstring,
int hf_string, const char *label) {
guint32 size;
gint32 i, num_strings;
const guint8 *retVal;
proto_tree *string_tree;
+ gint start;
proto_tree_add_item_ret_int(tree, hf_numstring, tvb, offset, 4, encoding, &num_strings);
offset += 4;
+ if (num_strings == 0) {
+ return offset;
+ }
+
+ start = offset;
/* Create the string node with a fake string, the replace it later */
- string_tree = proto_tree_add_subtree(tree, tvb, offset, param_length-8, ett_rtps_seq_string, NULL, label);
+ string_tree = proto_tree_add_subtree(tree, tvb, offset, -1, ett_rtps_seq_string, NULL, label);
for (i = 0; i < num_strings; ++i) {
size = tvb_get_guint32(tvb, offset, encoding);
@@ -2368,6 +2374,7 @@ gint rtps_util_add_seq_string(proto_tree *tree, tvbuff_t *tvb, gint offset,
offset += (4 + ((size + 3) & 0xfffffffc));
}
+ proto_item_set_len(string_tree, offset - start);
return offset;
}
@@ -4931,7 +4938,7 @@ static gboolean dissect_parameter_sequence_v1(proto_tree *rtps_parameter_tree, p
case PID_PARTITION:
ENSURE_LENGTH(4);
rtps_util_add_seq_string(rtps_parameter_tree, tvb, offset, encoding,
- param_length, hf_rtps_param_partition_num, hf_rtps_param_partition, "name");
+ hf_rtps_param_partition_num, hf_rtps_param_partition, "name");
break;
/* 0...2...........7...............15.............23...............31
@@ -5219,7 +5226,7 @@ static gboolean dissect_parameter_sequence_v1(proto_tree *rtps_parameter_tree, p
temp_offset = rtps_util_add_string(rtps_parameter_tree, tvb, temp_offset,
hf_rtps_param_filter_expression, encoding);
/*temp_offset = */rtps_util_add_seq_string(rtps_parameter_tree, tvb, temp_offset,
- encoding, param_length, hf_rtps_param_expression_parameters_num,
+ encoding, hf_rtps_param_expression_parameters_num,
hf_rtps_param_expression_parameters, "expressionParameters");
break;
}
@@ -10825,7 +10832,7 @@ void proto_register_rtps(void) {
},
{ &hf_rtps_param_partition_num,
- { "Size", "rtps.param.partition_num",
+ { "Number of partition names", "rtps.param.partition_num",
FT_INT32, BASE_DEC, NULL, 0,
NULL, HFILL }
},
diff --git a/epan/dissectors/packet-rtps.h b/epan/dissectors/packet-rtps.h
index ee3a0be24c..c934f4fd92 100644
--- a/epan/dissectors/packet-rtps.h
+++ b/epan/dissectors/packet-rtps.h
@@ -586,7 +586,7 @@ extern void rtps_util_add_durability_service_qos(proto_tree *tree, tvbuff_t * tv
extern void rtps_util_add_liveliness_qos(proto_tree *tree, tvbuff_t * tvb, gint offset,
const guint encoding);
extern gint rtps_util_add_seq_string(proto_tree *tree, tvbuff_t* tvb, gint offset,
- const guint encoding, int param_length, int hf_numstring,
+ const guint encoding, int hf_numstring,
int hf_string, const char *label);
extern gint rtps_util_add_seq_octets(proto_tree *tree, packet_info *pinfo, tvbuff_t* tvb,
gint offset, const guint encoding, int param_length, int hf_id);