fix(mbedtls): fix mbedtls dynamic resource memory leaks and RSA cert drop earlier

RX process caches the session information in "ssl->in_ctr" not in "ssl->in_buf".
So when freeing the SSL, can't free the "ssl->in_ctr", because the "ssl->in_buf"
is empty.

Make the RX process like TX process, and cache the session information in
"ssl->in_buf", so that the cache buffer can be freed when freeing the SSL.

Closes https://github.com/espressif/esp-idf/issues/6104
This commit is contained in:
Dong Heng
2020-11-12 15:17:21 +08:00
committed by bot
parent 2558830339
commit 1c9592efc4
4 changed files with 59 additions and 16 deletions

View File

@@ -33,9 +33,6 @@
\
if ((_ret = _fn) != 0) { \
ESP_LOGV(TAG, "\"%s\" result is -0x%x", # _fn, -_ret); \
if (_ret == MBEDTLS_ERR_SSL_CONN_EOF) {\
return 0; \
} \
TRACE_CHECK(_fn, "fail"); \
return _ret; \
} \
@@ -80,6 +77,8 @@ void esp_mbedtls_free_cacert(mbedtls_ssl_context *ssl);
#ifdef CONFIG_MBEDTLS_DYNAMIC_FREE_PEER_CERT
void esp_mbedtls_free_peer_cert(mbedtls_ssl_context *ssl);
bool esp_mbedtls_ssl_is_rsa(mbedtls_ssl_context *ssl);
#endif
#endif /* _DYNAMIC_IMPL_H_ */