Improve handling of short MQTT PDUs.

This is a "good-enough" fix for now until a more comprehensive fix
is committed to handle the case of the (variable size) PDU
length field being split across TCPO segments.

Change-Id: I57e8f5e9d7a9855fac320e8843b82a273ffb7cc5
Reviewed-on: https://code.wireshark.org/review/1748
Reviewed-by: Bill Meier <wmeier@newsguy.com>
This commit is contained in:
Bill Meier 2014-05-23 11:42:49 -04:00
parent 0eafcb9a04
commit 5896e2c621
1 changed files with 17 additions and 1 deletions

View File

@ -418,11 +418,27 @@ static int dissect_mqtt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, voi
return tvb_captured_length(tvb);
}
/**
"The minimum size of MQTT Packet is 2 bytes(Ping Req, Ping Rsp,
Disconnect), and the maximum size is 256MB. Hence minimum fixed
length should be 2 bytes for tcp_dissect_pdu.
If the length filed is spread across two TCP segments, then we have a
problem, because exception will be raised. So long as MQTT length
field(although spread over 4 bytes) is present within single TCP
segment we shouldn't have any issue by calling tcp_dissect_pdu with
minimum length set to 2."
XXX: ToDo: Commit a fix for the case of the length field spread across TCP segments.
**/
static int dissect_mqtt_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
{
tcp_dissect_pdus(tvb, pinfo, tree,
reassemble_mqtt_over_tcp,
5, /* Length can be determined within 5 bytes */
2, /* Length can be determined within 5 bytes */
get_mqtt_pdu_len,
dissect_mqtt, data);