]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
set_client_ciphersuite(): Fix for potential UB if session->cipher is NULL
authorAlexey Fofanov <avoget@gmail.com>
Wed, 18 Oct 2023 11:23:22 +0000 (14:23 +0300)
committerTomas Mraz <tomas@openssl.org>
Mon, 13 Nov 2023 11:52:43 +0000 (12:52 +0100)
This currently cannot happen without an application overriding
the session with some bogus data so this is an ossl_assert()
check.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22418)

ssl/statem/statem_clnt.c

index cbf5a57bebf47c31fb82c5b9edbd29388e0b4b3c..3b3c51e41c10d1714db3671b960bfaab5b42296f 100644 (file)
@@ -1427,6 +1427,10 @@ static int set_client_ciphersuite(SSL_CONNECTION *s,
         if (SSL_CONNECTION_IS_TLS13(s)) {
             const EVP_MD *md = ssl_md(sctx, c->algorithm2);
 
+            if (!ossl_assert(s->session->cipher != NULL)) {
+                SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR);
+                return 0;
+            }
             /*
              * In TLSv1.3 it is valid for the server to select a different
              * ciphersuite as long as the hash is the same.