adafruit / Adafruit_MQTT_Library

Arduino library for MQTT support
MIT License
571 stars 292 forks source link

Message type not checked in readSubscription #147

Closed ACE1046 closed 5 years ago

ACE1046 commented 5 years ago

Message type not checked in function Adafruit_MQTT_Subscribe *Adafruit_MQTT::readSubscription(int16_t timeout). This results in any unexpected packed to be misinterpreted as PUBLISH. In example, if ping response (PINGRESP) arrives after ping timeout, it is parsed as duplicated last subscription. Looks like same problem in this issue: #7 Log file for example:

MQTT ping packet:
      [0xC0],   [0x00], 
Client sendPacket returned: 2
Read data:        [0xD0], 
Packet Type:          [0xD0], 
Read data:        [0x00], 
Packet Length:  0
Packet len: 2
      [0xD0],   [0x00],    // PINGRESP packet, 2 bytes
Looking for subscription len 13  // parsed as PUBLISH
Found sub #55 Data len: 99
Data: 22
22
brentru commented 5 years ago

Merged into master, closing...