aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorFlavio Santes <flavio.santes@1byt3.com>2017-11-08 22:55:30 -0500
committerStig Bjørlykke <stig@bjorlykke.org>2017-11-09 08:45:04 +0000
commit43678551636f9845da4d52f48f8e82931f6b1c80 (patch)
tree0568e5a469b3fe62f798be4ea8042b0387898734 /epan
parentafb252355bebee80673ea904c6b510aeaf10feb5 (diff)
dissector/mqtt: Rewrite the SUBSCRIBE payload size computation
- FIX: subtract the property length from the message length - Replace the 'for' loop by a 'while' loop, now that the arithmetic is done before. TODO: It's a protocol error (v5.0)/violation (v3.1.1) not to include the payload in the SUBSCRIBE control packet. It would be nice to display a "malformed packet legend" in such that case. Change-Id: I99ef3862aa19b3a31ea03d1c194e54f489674115 Signed-off-by: Flavio Santes <flavio.santes@1byt3.com> Reviewed-on: https://code.wireshark.org/review/24313 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Tested-by: Petri Dish Buildbot Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
Diffstat (limited to 'epan')
-rw-r--r--epan/dissectors/packet-mqtt.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/epan/dissectors/packet-mqtt.c b/epan/dissectors/packet-mqtt.c
index 9894c21dc6..cee28a3c42 100644
--- a/epan/dissectors/packet-mqtt.c
+++ b/epan/dissectors/packet-mqtt.c
@@ -839,12 +839,19 @@ static int dissect_mqtt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, voi
proto_tree_add_item(mqtt_tree, hf_mqtt_msgid, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
+ /* Subtract the Packet Id size to compute the Payload length */
+ mqtt_msg_len -= 2;
+
if (mqtt->runtime_proto_version == MQTT_PROTO_V50)
{
- offset += dissect_mqtt_properties(tvb, mqtt_tree, offset);
+ guint32 mqtt_prop_offset = dissect_mqtt_properties(tvb, mqtt_tree, offset);
+ offset += mqtt_prop_offset;
+
+ /* Subtract the Property offset to compute the Payload length */
+ mqtt_msg_len -= mqtt_prop_offset;
}
- for(mqtt_msg_len -= 2; mqtt_msg_len > 0;)
+ while (mqtt_msg_len > 0)
{
mqtt_str_len = tvb_get_ntohs(tvb, offset);
proto_tree_add_item(mqtt_tree, hf_mqtt_topic_len, tvb, offset, 2, ENC_BIG_ENDIAN);