Fix bug #52345: MQTT buffer length check seems wrong

Don't try to parse variable length part if it is not contained in message
This commit is contained in:
Dirk Ziegelmeier 2017-11-26 21:05:07 +01:00
parent ad47a46815
commit 2ceedfe097

View File

@ -705,7 +705,7 @@ mqtt_message_received(mqtt_client_t *client, u8_t fixed_hdr_idx, u16_t length, u
u16_t payload_length = length;
u8_t qos = MQTT_CTL_PACKET_QOS(client->rx_buffer[0]);
if (client->msg_idx <= MQTT_VAR_HEADER_BUFFER_LEN) {
if ((client->msg_idx <= MQTT_VAR_HEADER_BUFFER_LEN) && (length > 0)) {
/* Should have topic and pkt id*/
u8_t *topic;
u16_t after_topic;