]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Fix memory leaks in ssl_old_test.c
authorBernd Edlinger <bernd.edlinger@hotmail.de>
Mon, 11 Sep 2023 10:26:46 +0000 (12:26 +0200)
committerBernd Edlinger <bernd.edlinger@hotmail.de>
Wed, 13 Sep 2023 12:30:34 +0000 (14:30 +0200)
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)

test/ssl_old_test.c

index 21834b1a36313c8f793d3797ca093f16dd11920f..fe168472d3022b1dfd2d5c75138ae69214259772 100644 (file)
@@ -1535,8 +1535,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