Merge branch 'bugfix/smtp_client_v4.4' into 'release/v4.4'

smtp_client: Fix heap leakage (v4.4)

See merge request espressif/esp-idf!17794
pull/8934/head
Mahavir Jain 2022-04-19 16:24:35 +08:00
commit 0c6ad1b7ba
1 zmienionych plików z 7 dodań i 1 usunięć

Wyświetl plik

@ -100,6 +100,7 @@ static int write_and_get_response(mbedtls_net_context *sock_fd, unsigned char *b
do { do {
len = DATA_SIZE - 1; len = DATA_SIZE - 1;
memset(data, 0, DATA_SIZE);
ret = mbedtls_net_recv(sock_fd, data, len); ret = mbedtls_net_recv(sock_fd, data, len);
if (ret <= 0) { if (ret <= 0) {
@ -153,6 +154,7 @@ static int write_ssl_and_get_response(mbedtls_ssl_context *ssl, unsigned char *b
do { do {
len = DATA_SIZE - 1; len = DATA_SIZE - 1;
memset(data, 0, DATA_SIZE);
ret = mbedtls_ssl_read(ssl, data, len); ret = mbedtls_ssl_read(ssl, data, len);
if (ret == MBEDTLS_ERR_SSL_WANT_READ || ret == MBEDTLS_ERR_SSL_WANT_WRITE) { if (ret == MBEDTLS_ERR_SSL_WANT_READ || ret == MBEDTLS_ERR_SSL_WANT_WRITE) {
@ -482,8 +484,12 @@ static void smtp_client_task(void *pvParameters)
ret = 0; /* No errors */ ret = 0; /* No errors */
exit: exit:
mbedtls_ssl_session_reset(&ssl);
mbedtls_net_free(&server_fd); mbedtls_net_free(&server_fd);
mbedtls_x509_crt_free(&cacert);
mbedtls_ssl_free(&ssl);
mbedtls_ssl_config_free(&conf);
mbedtls_ctr_drbg_free(&ctr_drbg);
mbedtls_entropy_free(&entropy);
if (ret != 0) { if (ret != 0) {
mbedtls_strerror(ret, buf, 100); mbedtls_strerror(ret, buf, 100);