]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Fix memory leak in tls_parse_ctos_psk()
authorNiels Dossche <7771979+nielsdos@users.noreply.github.com>
Wed, 9 Oct 2024 13:42:37 +0000 (15:42 +0200)
committerTomas Mraz <tomas@openssl.org>
Fri, 11 Oct 2024 12:54:25 +0000 (14:54 +0200)
`sess` is not NULL at this point, and is freed on the success path, but
not on the error path. Fix this by going to the `err` label such that
`SSL_SESSION_free(sess)` is called.

CLA: trivial

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25643)

(cherry picked from commit b2474b287fbc7a24f0aa15e6808c6e3ef8287f23)

ssl/statem/extensions_srvr.c

index 3997493d87a82ca437fc5723d2a1d21f9deece17..8df67793d3c8f940fb56a7276afb0b37c80914f0 100644 (file)
@@ -1120,7 +1120,7 @@ int tls_parse_ctos_psk(SSL_CONNECTION *s, PACKET *pkt, unsigned int context,
 
             if (sesstmp == NULL) {
                 SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR);
-                return 0;
+                goto err;
             }
             SSL_SESSION_free(sess);
             sess = sesstmp;