mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-31 19:24:33 +02:00
Merge branch 'fix/esp_tls_fix_memory_leak_v4.2' into 'release/v4.2'
Fix/esp tls fix memory leak v4.2 See merge request espressif/esp-idf!12085
This commit is contained in:
@@ -578,6 +578,7 @@ esp_err_t esp_mbedtls_set_global_ca_store(const unsigned char *cacert_pem_buf, c
|
|||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
ESP_LOGE(TAG, "mbedtls_x509_crt_parse returned -0x%x", -ret);
|
ESP_LOGE(TAG, "mbedtls_x509_crt_parse returned -0x%x", -ret);
|
||||||
mbedtls_x509_crt_free(global_cacert);
|
mbedtls_x509_crt_free(global_cacert);
|
||||||
|
free(global_cacert);
|
||||||
global_cacert = NULL;
|
global_cacert = NULL;
|
||||||
return ESP_FAIL;
|
return ESP_FAIL;
|
||||||
} else if (ret > 0) {
|
} else if (ret > 0) {
|
||||||
@@ -596,6 +597,7 @@ void esp_mbedtls_free_global_ca_store(void)
|
|||||||
{
|
{
|
||||||
if (global_cacert) {
|
if (global_cacert) {
|
||||||
mbedtls_x509_crt_free(global_cacert);
|
mbedtls_x509_crt_free(global_cacert);
|
||||||
|
free(global_cacert);
|
||||||
global_cacert = NULL;
|
global_cacert = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -157,6 +157,11 @@ static esp_err_t set_client_config(const char *hostname, size_t hostlen, esp_tls
|
|||||||
return ESP_ERR_WOLFSSL_CTX_SETUP_FAILED;
|
return ESP_ERR_WOLFSSL_CTX_SETUP_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cfg->crt_bundle_attach != NULL) {
|
||||||
|
ESP_LOGE(TAG,"use_crt_bundle not supported in wolfssl");
|
||||||
|
return ESP_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
if (cfg->use_global_ca_store == true) {
|
if (cfg->use_global_ca_store == true) {
|
||||||
if ((esp_load_wolfssl_verify_buffer(tls, global_cacert, global_cacert_pem_bytes, FILE_TYPE_CA_CERT, &ret)) != ESP_OK) {
|
if ((esp_load_wolfssl_verify_buffer(tls, global_cacert, global_cacert_pem_bytes, FILE_TYPE_CA_CERT, &ret)) != ESP_OK) {
|
||||||
ESP_LOGE(TAG, "Error in loading certificate verify buffer, returned %d", ret);
|
ESP_LOGE(TAG, "Error in loading certificate verify buffer, returned %d", ret);
|
||||||
@@ -218,11 +223,6 @@ static esp_err_t set_client_config(const char *hostname, size_t hostlen, esp_tls
|
|||||||
return ESP_FAIL;
|
return ESP_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cfg->crt_bundle_attach != NULL) {
|
|
||||||
ESP_LOGE(TAG,"use_crt_bundle not supported in wolfssl");
|
|
||||||
return ESP_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
tls->priv_ssl =(void *)wolfSSL_new( (WOLFSSL_CTX *)tls->priv_ctx);
|
tls->priv_ssl =(void *)wolfSSL_new( (WOLFSSL_CTX *)tls->priv_ctx);
|
||||||
if (!tls->priv_ssl) {
|
if (!tls->priv_ssl) {
|
||||||
ESP_LOGE(TAG, "Create wolfSSL failed");
|
ESP_LOGE(TAG, "Create wolfSSL failed");
|
||||||
|
Reference in New Issue
Block a user