mqtt: Use guint for offset
Change-Id: Ie7b4a540e68121dbe5cd14a9aac80a1f9aae90b3 Reviewed-on: https://code.wireshark.org/review/24342 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Reviewed-by: Anders Broman <a.broman58@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Roland Knall <rknall@gmail.com>
This commit is contained in:
parent
f35aa91c1a
commit
eaee0678ce
|
@ -491,7 +491,7 @@ static void mqtt_user_decode_message(proto_tree *tree, proto_tree *mqtt_tree, pa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static guint32 dissect_string(tvbuff_t *tvb, proto_tree *tree, guint32 offset, int hf_len, int hf_value)
|
static guint dissect_string(tvbuff_t *tvb, proto_tree *tree, guint offset, int hf_len, int hf_value)
|
||||||
{
|
{
|
||||||
guint16 prop_len;
|
guint16 prop_len;
|
||||||
|
|
||||||
|
@ -503,15 +503,15 @@ static guint32 dissect_string(tvbuff_t *tvb, proto_tree *tree, guint32 offset, i
|
||||||
}
|
}
|
||||||
|
|
||||||
/* MQTT v5.0: dissect the MQTT properties */
|
/* MQTT v5.0: dissect the MQTT properties */
|
||||||
static guint32 dissect_mqtt_properties(tvbuff_t *tvb, proto_tree *mqtt_tree, guint32 offset)
|
static guint dissect_mqtt_properties(tvbuff_t *tvb, proto_tree *mqtt_tree, guint offset)
|
||||||
{
|
{
|
||||||
proto_tree *mqtt_prop_tree;
|
proto_tree *mqtt_prop_tree;
|
||||||
proto_item *ti;
|
proto_item *ti;
|
||||||
guint64 vbi;
|
guint64 vbi;
|
||||||
|
|
||||||
const guint32 mqtt_prop_offset = dissect_uleb128(tvb, offset, &vbi);
|
const guint mqtt_prop_offset = dissect_uleb128(tvb, offset, &vbi);
|
||||||
/* Property Length field can be stored in uint32 */
|
/* Property Length field can be stored in uint32 */
|
||||||
const guint32 mqtt_prop_len = (guint32)vbi;
|
const guint mqtt_prop_len = (gint)vbi;
|
||||||
|
|
||||||
/* Add the MQTT branch to the main tree */
|
/* Add the MQTT branch to the main tree */
|
||||||
ti = proto_tree_add_item(mqtt_tree, hf_mqtt_property, tvb, offset, mqtt_prop_offset + mqtt_prop_len, ENC_NA);
|
ti = proto_tree_add_item(mqtt_tree, hf_mqtt_property, tvb, offset, mqtt_prop_offset + mqtt_prop_len, ENC_NA);
|
||||||
|
@ -520,7 +520,7 @@ static guint32 dissect_mqtt_properties(tvbuff_t *tvb, proto_tree *mqtt_tree, gui
|
||||||
proto_tree_add_item(mqtt_prop_tree, hf_mqtt_property_len, tvb, offset, mqtt_prop_offset, ENC_BIG_ENDIAN);
|
proto_tree_add_item(mqtt_prop_tree, hf_mqtt_property_len, tvb, offset, mqtt_prop_offset, ENC_BIG_ENDIAN);
|
||||||
offset += mqtt_prop_offset;
|
offset += mqtt_prop_offset;
|
||||||
|
|
||||||
const guint32 bytes_to_read = offset + mqtt_prop_len;
|
const guint bytes_to_read = offset + mqtt_prop_len;
|
||||||
while (offset < bytes_to_read)
|
while (offset < bytes_to_read)
|
||||||
{
|
{
|
||||||
guint8 prop_id = tvb_get_guint8(tvb, offset);
|
guint8 prop_id = tvb_get_guint8(tvb, offset);
|
||||||
|
@ -608,7 +608,7 @@ static int dissect_mqtt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, voi
|
||||||
conversation_t *conv;
|
conversation_t *conv;
|
||||||
mqtt_conv_t *mqtt;
|
mqtt_conv_t *mqtt;
|
||||||
|
|
||||||
guint32 offset = 0;
|
guint offset = 0;
|
||||||
static const int *publish_fields[] = {
|
static const int *publish_fields[] = {
|
||||||
&hf_mqtt_msg_type,
|
&hf_mqtt_msg_type,
|
||||||
&hf_mqtt_dup_flag,
|
&hf_mqtt_dup_flag,
|
||||||
|
@ -814,8 +814,7 @@ static int dissect_mqtt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, voi
|
||||||
|
|
||||||
if (mqtt->runtime_proto_version == MQTT_PROTO_V50)
|
if (mqtt->runtime_proto_version == MQTT_PROTO_V50)
|
||||||
{
|
{
|
||||||
guint32 mqtt_prop_offset = dissect_mqtt_properties(tvb, mqtt_tree, offset);
|
offset += dissect_mqtt_properties(tvb, mqtt_tree, offset);
|
||||||
offset += mqtt_prop_offset;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mqtt_payload_len = tvb_reported_length(tvb) - offset;
|
mqtt_payload_len = tvb_reported_length(tvb) - offset;
|
||||||
|
@ -838,11 +837,10 @@ static int dissect_mqtt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, voi
|
||||||
|
|
||||||
if (mqtt->runtime_proto_version == MQTT_PROTO_V50)
|
if (mqtt->runtime_proto_version == MQTT_PROTO_V50)
|
||||||
{
|
{
|
||||||
guint32 mqtt_prop_offset = dissect_mqtt_properties(tvb, mqtt_tree, offset);
|
offset += dissect_mqtt_properties(tvb, mqtt_tree, offset);
|
||||||
offset += mqtt_prop_offset;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while (offset < (guint32)tvb_reported_length(tvb))
|
while (offset < tvb_reported_length(tvb))
|
||||||
{
|
{
|
||||||
mqtt_str_len = tvb_get_ntohs(tvb, offset);
|
mqtt_str_len = tvb_get_ntohs(tvb, offset);
|
||||||
proto_tree_add_item(mqtt_tree, hf_mqtt_topic_len, tvb, offset, 2, ENC_BIG_ENDIAN);
|
proto_tree_add_item(mqtt_tree, hf_mqtt_topic_len, tvb, offset, 2, ENC_BIG_ENDIAN);
|
||||||
|
@ -874,7 +872,7 @@ 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);
|
proto_tree_add_item(mqtt_tree, hf_mqtt_msgid, tvb, offset, 2, ENC_BIG_ENDIAN);
|
||||||
offset += 2;
|
offset += 2;
|
||||||
|
|
||||||
while (offset < (guint32)tvb_reported_length(tvb))
|
while (offset < tvb_reported_length(tvb))
|
||||||
{
|
{
|
||||||
mqtt_str_len = tvb_get_ntohs(tvb, offset);
|
mqtt_str_len = tvb_get_ntohs(tvb, offset);
|
||||||
proto_tree_add_item(mqtt_tree, hf_mqtt_topic_len, tvb, offset, 2, ENC_BIG_ENDIAN);
|
proto_tree_add_item(mqtt_tree, hf_mqtt_topic_len, tvb, offset, 2, ENC_BIG_ENDIAN);
|
||||||
|
@ -897,7 +895,7 @@ static int dissect_mqtt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, voi
|
||||||
offset += dissect_mqtt_properties(tvb, mqtt_tree, offset);
|
offset += dissect_mqtt_properties(tvb, mqtt_tree, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (offset < (guint32)tvb_reported_length(tvb))
|
while (offset < tvb_reported_length(tvb))
|
||||||
{
|
{
|
||||||
proto_tree_add_item(mqtt_tree, hf_mqtt_suback_qos, tvb, offset, 1, ENC_BIG_ENDIAN);
|
proto_tree_add_item(mqtt_tree, hf_mqtt_suback_qos, tvb, offset, 1, ENC_BIG_ENDIAN);
|
||||||
offset += 1;
|
offset += 1;
|
||||||
|
|
Loading…
Reference in New Issue