Skip to content

Commit b7838a3

Browse files
authored
Merge pull request #148 from ACE1046/master
Message type check in readSubscription (#147)
2 parents 9eb37ef + 417d342 commit b7838a3

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Adafruit_MQTT.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,9 @@ Adafruit_MQTT_Subscribe *Adafruit_MQTT::readSubscription(int16_t timeout) {
463463
DEBUG_PRINT("Packet len: "); DEBUG_PRINTLN(len);
464464
DEBUG_PRINTBUFFER(buffer, len);
465465

466+
if (len<3) return NULL;
467+
if ((buffer[0] & 0xF0) != (MQTT_CTRL_PUBLISH) << 4) return NULL;
468+
466469
// Parse out length of packet.
467470
topiclen = buffer[3];
468471
DEBUG_PRINT(F("Looking for subscription len ")); DEBUG_PRINTLN(topiclen);

0 commit comments

Comments
 (0)