Skip to content

Commit 02cd9f1

Browse files
author
Veijo Pesonen
committed
[ESP8266] adds an error check for data overflow from modem side
1 parent 28d5477 commit 02cd9f1

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

components/wifi/esp8266-driver/ESP8266/ESP8266.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,10 @@ int32_t ESP8266::_recv_tcp_passive(int id, void *data, uint32_t amount, uint32_t
715715

716716
// update internal variable tcp_data_avbl to reflect the remaining data
717717
if (_sock_i[id].tcp_data_rcvd > 0) {
718+
if (_sock_i[id].tcp_data_rcvd > (int32_t)amount) {
719+
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_DRIVER, MBED_ERROR_CODE_EBADMSG), \
720+
"ESP8266::_recv_tcp_passive() too much data from modem\n");
721+
}
718722
if (_sock_i[id].tcp_data_avbl > _sock_i[id].tcp_data_rcvd) {
719723
_sock_i[id].tcp_data_avbl -= _sock_i[id].tcp_data_rcvd;
720724
} else {

0 commit comments

Comments
 (0)