diff options
author | Paul Emge <paul.emge@digidescorp.com> | 2015-08-06 11:00:22 -0500 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2015-08-21 07:25:07 +0000 |
commit | 805578636bb2a6df59b74489c9f77295ddc74480 (patch) | |
tree | 2bef31331ab1b1e3ab4ffe5f5091eae086bc4f79 /epan/dissectors/packet-mrp-mvrp.c | |
parent | a5fe54d180b2723e621fa61104002353e897a828 (diff) |
Fix bug with MVRP dissection where only one message was dissected.
Fix whitespace and replace tvb_captured_length with tvb_reported_length
Change-Id: I3952e7a1ac00b68e6f6eb1283977bc6299b0baaf
Reviewed-on: https://code.wireshark.org/review/9900
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>
Diffstat (limited to 'epan/dissectors/packet-mrp-mvrp.c')
-rw-r--r-- | epan/dissectors/packet-mrp-mvrp.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/epan/dissectors/packet-mrp-mvrp.c b/epan/dissectors/packet-mrp-mvrp.c index 2be8238073..843f6dc6c0 100644 --- a/epan/dissectors/packet-mrp-mvrp.c +++ b/epan/dissectors/packet-mrp-mvrp.c @@ -229,9 +229,9 @@ dissect_mvrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) guint8 attribute_length; guint16 number_of_values; guint offset = 0; - int vect_attr_len; - int msg_offset; /* Use when handling multiple messages. This points to current msg being decoded. */ - int vect_offset; /* Use when handling multiple vector attributes. This points to the current vector attribute being decoded. */ + unsigned int vect_attr_len; + unsigned int msg_offset; /* Use when handling multiple messages. This points to current msg being decoded. */ + unsigned int vect_offset; /* Use when handling multiple vector attributes. This points to the current vector attribute being decoded. */ ti = proto_tree_add_item(tree, proto_mvrp, tvb, 0, -1, ENC_NA); mvrp_tree = proto_item_add_subtree(ti, ett_mvrp); @@ -244,7 +244,7 @@ dissect_mvrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) * Attribute Type and Attribute Length (guaranteed to not be 0x0000). */ msg_offset = 0; - while (tvb_get_ntohs(tvb, MVRP_ATTRIBUTE_TYPE_OFFSET + msg_offset) != MVRP_END_MARK) { + while (MVRP_ATTRIBUTE_TYPE_OFFSET + msg_offset < tvb_reported_length(tvb) && tvb_get_ntohs(tvb, MVRP_ATTRIBUTE_TYPE_OFFSET + msg_offset) != MVRP_END_MARK) { attribute_type = tvb_get_guint8(tvb, MVRP_ATTRIBUTE_TYPE_OFFSET + msg_offset); attribute_length = tvb_get_guint8(tvb, MVRP_ATTRIBUTE_LENGTH_OFFSET + msg_offset); @@ -284,7 +284,7 @@ dissect_mvrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) * instead of a Vector Header (guaranteed to not be 0x0000). */ vect_offset = 0; - while (tvb_get_ntohs(tvb, MVRP_VECTOR_HEADER_OFFSET + msg_offset + vect_offset) != MVRP_END_MARK) { + while (MVRP_VECTOR_HEADER_OFFSET + msg_offset + vect_offset < tvb_reported_length(tvb) && tvb_get_ntohs(tvb, MVRP_VECTOR_HEADER_OFFSET + msg_offset + vect_offset) != MVRP_END_MARK) { /* MVRP VectorAttribute is a group of fields * * Contains VectorHeader (2 bytes) @@ -331,15 +331,19 @@ dissect_mvrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) vect_offset += vect_attr_len; /* Move to next Vector Attribute, if there is one */ } /* Multiple VectorAttribute while() */ - proto_tree_add_item(attr_list_tree, hf_mvrp_end_mark, tvb, offset, 2, ENC_BIG_ENDIAN); /* VectorAttribute EndMark */ + if (MVRP_VECTOR_HEADER_OFFSET + msg_offset + vect_offset < tvb_reported_length(tvb)) { + proto_tree_add_item(attr_list_tree, hf_mvrp_end_mark, tvb, offset, 2, ENC_BIG_ENDIAN); /* VectorAttribute EndMark */ + } proto_item_set_len(attr_list_ti, vect_offset); /*without an endmark*/ - msg_offset += vect_offset + 2; /* + endmark; Move to next Message, if there is one */ + msg_offset += vect_offset + 4; /* + endmark; Move to next Message, if there is one */ proto_item_set_len(msg_ti, vect_offset + 2); /*length of message*/ } /* Multiple Message while() */ - proto_tree_add_item(mvrp_tree, hf_mvrp_end_mark, tvb, offset+2, 2, ENC_BIG_ENDIAN); /* Message EndMark */ + if (MVRP_ATTRIBUTE_TYPE_OFFSET + msg_offset < tvb_reported_length(tvb)) { + proto_tree_add_item(mvrp_tree, hf_mvrp_end_mark, tvb, offset+2, 2, ENC_BIG_ENDIAN); /* Message EndMark */ + } } } |