Commit 16700244 authored by Deomid Ryabkov's avatar Deomid Ryabkov Committed by Cesanta Bot

Fix parsing of MQTT QoS > 0 PUBLISH messages

Message ID comes after topic, not before.

PUBLISHED_FROM=1ec2a56e290b67061b18c745671dc7f089b9cc0d
parent 49ca223e
...@@ -9667,12 +9667,11 @@ MG_INTERNAL int parse_mqtt(struct mbuf *io, struct mg_mqtt_message *mm) { ...@@ -9667,12 +9667,11 @@ MG_INTERNAL int parse_mqtt(struct mbuf *io, struct mg_mqtt_message *mm) {
mm->message_id = getu16(p); mm->message_id = getu16(p);
break; break;
case MG_MQTT_CMD_PUBLISH: { 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); mm->message_id = getu16(p);
p += 2; p += 2;
} }
p = scanto(p, &mm->topic);
mm->payload.p = p; mm->payload.p = p;
mm->payload.len = end - p; mm->payload.len = end - p;
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment