aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-lldp.c
diff options
context:
space:
mode:
authorAnish Bhatt <anish@chelsio.com>2014-06-12 23:54:31 -0700
committerEvan Huus <eapache@gmail.com>2014-06-19 18:22:44 +0000
commit0b245a4cf8a46110ef0803e091e11fd894e017b2 (patch)
tree1008dc8b40e8a1df92d8cecc786d6bbb29099fc1 /epan/dissectors/packet-lldp.c
parent3adc5b8c805878fb3bb299f7b9ce329c45675956 (diff)
Use the same offset += rtnValue logic for all TLV types, instead of a special case for chassis, port & ttl.
I've avoided using any mathematical checks even though tlv type vals increase linearly just in case they change in the future. Change-Id: I0ec7021df5b91543e12edf9ba8d9c4ac44ecb11c Signed-off-by: Anish Bhatt <anish@chelsio.com> Reviewed-on: https://code.wireshark.org/review/2193 Reviewed-by: Evan Huus <eapache@gmail.com>
Diffstat (limited to 'epan/dissectors/packet-lldp.c')
-rw-r--r--epan/dissectors/packet-lldp.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/epan/dissectors/packet-lldp.c b/epan/dissectors/packet-lldp.c
index 7562ef617a..dfcb1cc4cf 100644
--- a/epan/dissectors/packet-lldp.c
+++ b/epan/dissectors/packet-lldp.c
@@ -3178,7 +3178,10 @@ dissect_lldp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
lldp_tree = proto_item_add_subtree(ti, ett_lldp);
/* Get chassis id tlv */
- rtnValue = dissect_lldp_chassis_id(tvb, pinfo, lldp_tree, offset);
+ tempShort = tvb_get_ntohs(tvb, offset);
+ new_tvb = tvb_new_subset_length(tvb, offset, TLV_INFO_LEN(tempShort)+2);
+
+ rtnValue = dissect_lldp_chassis_id(new_tvb, pinfo, lldp_tree, 0);
if (rtnValue < 0)
{
col_set_str(pinfo->cinfo, COL_INFO, "Invalid Chassis ID TLV");
@@ -3186,10 +3189,13 @@ dissect_lldp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
return;
}
- offset = rtnValue;
+ offset += rtnValue;
/* Get port id tlv */
- rtnValue = dissect_lldp_port_id(tvb, pinfo, lldp_tree, offset);
+ tempShort = tvb_get_ntohs(tvb, offset);
+ new_tvb = tvb_new_subset_length(tvb, offset, TLV_INFO_LEN(tempShort)+2);
+
+ rtnValue = dissect_lldp_port_id(new_tvb, pinfo, lldp_tree, 0);
if (rtnValue < 0)
{
col_set_str(pinfo->cinfo, COL_INFO, "Invalid Port ID TLV");
@@ -3197,10 +3203,13 @@ dissect_lldp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
return;
}
- offset = rtnValue;
+ offset += rtnValue;
/* Get time to live tlv */
- rtnValue = dissect_lldp_time_to_live(tvb, pinfo, lldp_tree, offset);
+ tempShort = tvb_get_ntohs(tvb, offset);
+ new_tvb = tvb_new_subset_length(tvb, offset, TLV_INFO_LEN(tempShort)+2);
+
+ rtnValue = dissect_lldp_time_to_live(new_tvb, pinfo, lldp_tree, 0);
if (rtnValue < 0)
{
col_set_str(pinfo->cinfo, COL_INFO, "Invalid Time-to-Live TLV");
@@ -3208,7 +3217,8 @@ dissect_lldp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
return;
}
- offset = rtnValue;
+ offset += rtnValue;
+
/* Dissect optional tlv's until end-of-lldpdu is reached */
while (!reachedEnd)