From a3ede758427fa5c6627476438a4ba0ccdf0dd4c9 Mon Sep 17 00:00:00 2001 From: "Sergio R. Caprile" Date: Thu, 3 Nov 2022 11:26:08 -0300 Subject: [PATCH] Accept zero-length payload messages --- mongoose.c | 2 +- src/mqtt.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mongoose.c b/mongoose.c index 1ebd29c9..d5189943 100644 --- a/mongoose.c +++ b/mongoose.c @@ -3195,7 +3195,7 @@ int mg_mqtt_parse(const uint8_t *buf, size_t len, uint8_t version, m->id = (uint16_t) ((((uint16_t) p[0]) << 8) | p[1]); p += 2; } - if (p >= end) return MQTT_MALFORMED; + if (p > end) return MQTT_MALFORMED; if (version == 5) p += 1 + p[0]; // Skip options if (p > end) return MQTT_MALFORMED; m->data.ptr = (char *) p; diff --git a/src/mqtt.c b/src/mqtt.c index 5c712be4..1dffea3e 100644 --- a/src/mqtt.c +++ b/src/mqtt.c @@ -172,7 +172,7 @@ int mg_mqtt_parse(const uint8_t *buf, size_t len, uint8_t version, m->id = (uint16_t) ((((uint16_t) p[0]) << 8) | p[1]); p += 2; } - if (p >= end) return MQTT_MALFORMED; + if (p > end) return MQTT_MALFORMED; if (version == 5) p += 1 + p[0]; // Skip options if (p > end) return MQTT_MALFORMED; m->data.ptr = (char *) p;