mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-01-18 19:27:41 +00:00
Merge pull request #5353 from gstrauss/mbedtls_ssl_config_defaults-repeat
Reset dhm_P and dhm_G if config call repeated; avoid memory leak
This commit is contained in:
commit
73839e02a7
2
ChangeLog.d/mbedtls_ssl_comfig_defaults-memleak.txt
Normal file
2
ChangeLog.d/mbedtls_ssl_comfig_defaults-memleak.txt
Normal file
@ -0,0 +1,2 @@
|
||||
Bugfix
|
||||
* Fix memory leak if mbedtls_ssl_config_defaults() call is repeated
|
@ -3944,6 +3944,9 @@ int mbedtls_ssl_conf_dh_param_bin( mbedtls_ssl_config *conf,
|
||||
{
|
||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||
|
||||
mbedtls_mpi_free( &conf->dhm_P );
|
||||
mbedtls_mpi_free( &conf->dhm_G );
|
||||
|
||||
if( ( ret = mbedtls_mpi_read_binary( &conf->dhm_P, dhm_P, P_len ) ) != 0 ||
|
||||
( ret = mbedtls_mpi_read_binary( &conf->dhm_G, dhm_G, G_len ) ) != 0 )
|
||||
{
|
||||
@ -3959,6 +3962,9 @@ int mbedtls_ssl_conf_dh_param_ctx( mbedtls_ssl_config *conf, mbedtls_dhm_context
|
||||
{
|
||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||
|
||||
mbedtls_mpi_free( &conf->dhm_P );
|
||||
mbedtls_mpi_free( &conf->dhm_G );
|
||||
|
||||
if( ( ret = mbedtls_dhm_get_value( dhm_ctx, MBEDTLS_DHM_PARAM_P,
|
||||
&conf->dhm_P ) ) != 0 ||
|
||||
( ret = mbedtls_dhm_get_value( dhm_ctx, MBEDTLS_DHM_PARAM_G,
|
||||
|
Loading…
x
Reference in New Issue
Block a user