From 7151d2002917424336d158ec39eae3b3af17143b Mon Sep 17 00:00:00 2001 From: dimeg Date: Wed, 18 Aug 2010 21:12:26 +0000 Subject: Fix for Bug 5052: Good ZigBee Beacon detected as malformed In ZigBee 2006 the Tx-Offset is optional, while in the 2007 and later versions, the Tx-Offset is a required value. Since both 2006 and and 2007 versions have the same protocol version (2), we should treat the Tx-Offset as well as the update ID as optional elements git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@33842 f5534014-38df-0310-8fa8-9805f1628bb7 --- epan/dissectors/packet-zbee-nwk.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'epan/dissectors/packet-zbee-nwk.c') diff --git a/epan/dissectors/packet-zbee-nwk.c b/epan/dissectors/packet-zbee-nwk.c index 48af43c2e4..006220a53e 100644 --- a/epan/dissectors/packet-zbee-nwk.c +++ b/epan/dissectors/packet-zbee-nwk.c @@ -1378,19 +1378,24 @@ static void dissect_zbee_beacon(tvbuff_t *tvb, packet_info *pinfo, proto_tree *t col_append_fstr(pinfo->cinfo, COL_INFO, ", EPID: %s", print_eui64(epid)); } - /* In ZigBee 2007 and layer, the Tx-Offset is a required value. */ - tx_offset = tvb_get_letoh24(tvb, offset); - if (tree) { + /* + * In ZigBee 2006 the Tx-Offset is optional, while in the 2007 and + * later versions, the Tx-Offset is a required value. Since both 2006 and + * and 2007 versions have the same protocol version (2), we should treat + * the Tx-Offset as well as the update ID as optional elements + */ + if (tvb_bytes_exist(tvb, offset, 3)) { + tx_offset = tvb_get_letoh24(tvb, offset); proto_tree_add_uint(beacon_tree, hf_zbee_beacon_tx_offset, tvb, offset, 3, tx_offset); - } - offset += 3; + offset += 3; - /* Get and display the update ID. */ - temp = tvb_get_guint8(tvb, offset); - if (tree) { - proto_tree_add_uint(beacon_tree, hf_zbee_beacon_update_id, tvb, offset, sizeof(guint8), temp); + /* Get and display the update ID. */ + if(tvb_length_remaining(tvb, offset)) { + temp = tvb_get_guint8(tvb, offset); + proto_tree_add_uint(beacon_tree, hf_zbee_beacon_update_id, tvb, offset, sizeof(guint8), temp); + offset += sizeof(guint8); + } } - offset += sizeof(guint8); } else if (tvb_bytes_exist(tvb, offset, 3)) { /* In ZigBee 2004, the Tx-Offset is an optional value. */ -- cgit v1.2.3