Skip to content

Commit 11a8d5e

Browse files
aentingernooj
andauthored
Fix buffer overflow introduced in #44. (#71)
PR #44 introduced a buffer overflow bug that will corrupt the heap if the transmit payload size is increased after any send. Co-authored-by: Dr. Fred Nugen <[email protected]>
1 parent 46d65e3 commit 11a8d5e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/MqttClient.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,12 @@ void MqttClient::setConnectionTimeout(unsigned long timeout)
802802

803803
void MqttClient::setTxPayloadSize(unsigned short size)
804804
{
805+
if (_txPayloadBuffer) {
806+
free(_txPayloadBuffer);
807+
_txPayloadBuffer = NULL;
808+
_txPayloadBufferIndex = 0;
809+
}
810+
805811
_tx_payload_buffer_size = size;
806812
}
807813

0 commit comments

Comments
 (0)