Merge pull request #9366 from VeijoPesonen/bugfix-esp8266_verify_rcvd_data_len

ESP8266: add an error check for data overflow from modem side
pull/9787/head
Cruz Monrreal 2019-01-17 21:52:11 -06:00 committed by GitHub
commit 30e0d8f1f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 0 deletions

View File

@ -715,6 +715,10 @@ int32_t ESP8266::_recv_tcp_passive(int id, void *data, uint32_t amount, uint32_t
// update internal variable tcp_data_avbl to reflect the remaining data
if (_sock_i[id].tcp_data_rcvd > 0) {
if (_sock_i[id].tcp_data_rcvd > (int32_t)amount) {
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_DRIVER, MBED_ERROR_CODE_EBADMSG), \
"ESP8266::_recv_tcp_passive() too much data from modem\n");
}
if (_sock_i[id].tcp_data_avbl > _sock_i[id].tcp_data_rcvd) {
_sock_i[id].tcp_data_avbl -= _sock_i[id].tcp_data_rcvd;
} else {