1
0
mirror of https://github.com/adafruit/Adafruit_MQTT_Library.git synced 2025-09-06 16:06:36 +03:00

Adafruit_MQTT::publishPacket: Protect against memory corruption.

Avoid memory corruption from happening when data payload provided
in Adafruit_MQTT::publishPacket is greater than MAXBUFFERSIZE.

In order to do that, a helper function is being added to calculate
how much space is available for the payload after subtracting what
is used as the header.

Pull request https://github.com/adafruit/Adafruit_MQTT_Library/pull/166
Fixes https://github.com/adafruit/Adafruit_MQTT_Library/issues/109
Fixes https://github.com/adafruit/Adafruit_MQTT_Library/issues/122

Signed-off-by: Flavio Fernandes <flavio@flaviof.com>
This commit is contained in:
Flavio Fernandes
2020-08-29 15:56:43 -04:00
parent f63a37b6fb
commit d6f07ed4e4
2 changed files with 36 additions and 5 deletions

View File

@@ -262,7 +262,7 @@ private:
uint8_t connectPacket(uint8_t *packet);
uint8_t disconnectPacket(uint8_t *packet);
uint16_t publishPacket(uint8_t *packet, const char *topic, uint8_t *payload,
uint16_t bLen, uint8_t qos);
uint16_t bLen, uint8_t qos, uint16_t maxPacketLen = 0);
uint8_t subscribePacket(uint8_t *packet, const char *topic, uint8_t qos);
uint8_t unsubscribePacket(uint8_t *packet, const char *topic);
uint8_t pingPacket(uint8_t *packet);