Message type check in readSubscription (#147)

Added message type checking in readSubscription
https://github.com/adafruit/Adafruit_MQTT_Library/issues/147
This commit is contained in:
Anton ACE 2019-03-14 17:54:06 +03:00 committed by GitHub
parent 493a1cf590
commit 417d342078
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 0 deletions

View File

@ -463,6 +463,9 @@ Adafruit_MQTT_Subscribe *Adafruit_MQTT::readSubscription(int16_t timeout) {
DEBUG_PRINT("Packet len: "); DEBUG_PRINTLN(len);
DEBUG_PRINTBUFFER(buffer, len);
if (len<3) return NULL;
if ((buffer[0] & 0xF0) != (MQTT_CTRL_PUBLISH) << 4) return NULL;
// Parse out length of packet.
topiclen = buffer[3];
DEBUG_PRINT(F("Looking for subscription len ")); DEBUG_PRINTLN(topiclen);