net/mqtt: use rlen to calculate # of QoS items in SUBACK packet

The data->len of an inbound netbuf can be larger than a single
MQTT packet.  For instance when a PINGRESP is also included
in the same netbuf.  For this reason we should not be using
the data->len to determine how large the rest of the MQTT data is.

Specific Example: we've seen in testing that PINGRESP packets
can be included with a SUBACK packet in the same netbuf. Under
this case the current code uses the data->len incorrectly and
tries to find 3 QoS elements for the SUBACK packet when there
is only 1 (the rest of the data is for PINGRESP).

NOTE: A larger patch to iterate through the netbuf data parsing
individual MQTT packets will be needed to fix the MQTT subsys.
This patch only corrects the SUBACK parsing.

Change-Id: I7f6cebaaed9570b778d466de84331cf8c5060755
Signed-off-by: Michael Scott <michael.scott@linaro.org>
This commit is contained in:
Michael Scott 2017-02-24 16:44:39 -08:00 committed by Jukka Rissanen
commit fa5503fb44

View file

@ -815,7 +815,7 @@ int mqtt_unpack_suback(u8_t *buf, u16_t length, u16_t *pkt_id,
*pkt_id = ntohs(val_u16);
offset += PACKET_ID_SIZE;
*items = length - offset;
*items = rlen - PACKET_ID_SIZE;
/* no enough space to store the QoS */
if (*items > elements) {