summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbesher <beshoux@outlook.fr>2023-02-05 00:08:14 +0100
committerTodd Short <todd.short@me.com>2023-02-08 09:50:11 -0500
commit4cfae921af8809c1f1dd567629c6c3310a9218ca (patch)
tree90eebea9e7d8bc6fb59e01aedd50cd77f94feb47
parent510e4935ca728cf91820edcec55afb8e1f6aa5a2 (diff)
Fix a potential memory leak in apps/s_server.c
Allocate memory for a new SSL session. If any of these steps fail, free the key memory and the tmpsess object before returning 0 to prevent a memory leak. Fixes: #20110 CLA: trivial Reviewed-by: Paul Yang <kaishen.yy@antfin.com> Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Todd Short <todd.short@me.com> (Merged from https://github.com/openssl/openssl/pull/20213) (cherry picked from commit 8e2552b1eac4957214fed55457f64d7d5164ca37)
-rw-r--r--apps/s_server.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/apps/s_server.c b/apps/s_server.c
index 8a5ac4c14d..5fa98cd358 100644
--- a/apps/s_server.c
+++ b/apps/s_server.c
@@ -228,6 +228,7 @@ static int psk_find_session_cb(SSL *ssl, const unsigned char *identity,
|| !SSL_SESSION_set_cipher(tmpsess, cipher)
|| !SSL_SESSION_set_protocol_version(tmpsess, SSL_version(ssl))) {
OPENSSL_free(key);
+ SSL_SESSION_free(tmpsess);
return 0;
}
OPENSSL_free(key);