Fix parsing of MQTT QoS > 0 PUBLISH messages

Message ID comes after topic, not before.

PUBLISHED_FROM=1ec2a56e290b67061b18c745671dc7f089b9cc0d
This commit is contained in:
Deomid Ryabkov 2017-03-07 23:35:22 +00:00 committed by Cesanta Bot
parent 49ca223e9c
commit 16700244b0

View File

@ -9667,12 +9667,11 @@ MG_INTERNAL int parse_mqtt(struct mbuf *io, struct mg_mqtt_message *mm) {
mm->message_id = getu16(p);
break;
case MG_MQTT_CMD_PUBLISH: {
if (MG_MQTT_GET_QOS(header) > 0) {
p = scanto(p, &mm->topic);
if (mm->qos > 0) {
mm->message_id = getu16(p);
p += 2;
}
p = scanto(p, &mm->topic);
mm->payload.p = p;
mm->payload.len = end - p;
break;