From 16700244b0e930187953d44a8f3e7671eeeab94a Mon Sep 17 00:00:00 2001 From: Deomid Ryabkov Date: Tue, 7 Mar 2017 23:35:22 +0000 Subject: [PATCH] Fix parsing of MQTT QoS > 0 PUBLISH messages Message ID comes after topic, not before. PUBLISHED_FROM=1ec2a56e290b67061b18c745671dc7f089b9cc0d --- mongoose.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mongoose.c b/mongoose.c index 4dadab9b..26c15baa 100644 --- a/mongoose.c +++ b/mongoose.c @@ -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;