diff options
author | Bernd Edlinger <bernd.edlinger@hotmail.de> | 2023-09-11 12:26:46 +0200 |
---|---|---|
committer | Bernd Edlinger <bernd.edlinger@hotmail.de> | 2023-09-13 14:31:27 +0200 |
commit | ba3c334eca591cb46bf9eb8821363f49c846117d (patch) | |
tree | c0063a9ab6cefc3fbe806a96ccfd5361f74c2d12 | |
parent | 094c9297fa7463024a7ca139d3f90b508f49fd91 (diff) |
Fix memory leaks in ssl_old_test.c
This fixes a few memory leaks reported in #22049.
If SSL_CTX_set0_tmp_dh_pkey rejects the temp dh key
due to security restrictions (even when @SECLEVEL=0 is used!)
then the caller has to delete the PKEY object.
That is different to how the deprecated
SSL_CTX_set_tmp_dh_pkey was designed to work.
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22060)
(cherry picked from commit 21f0b80cd4b32ba80843b812b01a6056daf14093)
-rw-r--r-- | test/ssl_old_test.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/test/ssl_old_test.c b/test/ssl_old_test.c index d09d5ab3a9..09c9706a7c 100644 --- a/test/ssl_old_test.c +++ b/test/ssl_old_test.c @@ -1525,8 +1525,10 @@ int main(int argc, char *argv[]) ERR_print_errors(bio_err); goto end; } - SSL_CTX_set0_tmp_dh_pkey(s_ctx, dhpkey); - SSL_CTX_set0_tmp_dh_pkey(s_ctx2, dhpkey); + if (!SSL_CTX_set0_tmp_dh_pkey(s_ctx, dhpkey)) + EVP_PKEY_free(dhpkey); + if (!SSL_CTX_set0_tmp_dh_pkey(s_ctx2, dhpkey)) + EVP_PKEY_free(dhpkey); } #endif |