Skip to content

Commit 417d342

Browse files
authored
Message type check in readSubscription (#147)
Added message type checking in readSubscription #147
1 parent 493a1cf commit 417d342

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)