From db71c753aad7de09af1a667d1db0d5017c048f6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Cabral?= Date: Thu, 18 Apr 2019 14:32:01 +0100 Subject: [PATCH] FIX: mqtt_get_id wrong logic on msg size checks. This error was preventing the function from returning the right msg ID, returning always 0. --- lib/mqtt_msg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/mqtt_msg.c b/lib/mqtt_msg.c index 1ee803c..bf40aa4 100644 --- a/lib/mqtt_msg.c +++ b/lib/mqtt_msg.c @@ -307,13 +307,13 @@ uint16_t mqtt_get_id(uint8_t* buffer, uint16_t length) topiclen = buffer[i++] << 8; topiclen |= buffer[i++]; - if (i + topiclen >= length) + if (i + topiclen > length) return 0; i += topiclen; if (mqtt_get_qos(buffer) > 0) { - if (i + 2 >= length) + if (i + 2 > length) return 0; //i += 2; } else {