From: besher Date: Sat, 4 Feb 2023 23:08:14 +0000 (+0100) Subject: Fix a potential memory leak in apps/s_server.c X-Git-Tag: openssl-3.2.0-alpha1~1313 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8e2552b1eac4957214fed55457f64d7d5164ca37;p=thirdparty%2Fopenssl.git 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 Reviewed-by: Tomas Mraz Reviewed-by: Paul Dale Reviewed-by: Todd Short (Merged from https://github.com/openssl/openssl/pull/20213) --- diff --git a/apps/s_server.c b/apps/s_server.c index 0b794960f92..e822bcc0905 100644 --- a/apps/s_server.c +++ b/apps/s_server.c @@ -229,6 +229,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);