ssl_lib: added pointer SSL_CONNECTION check to NULL before dereferencing it in ossl_c...
authoratishkov <a.tishkov@aladdin.ru>
Tue, 24 Oct 2023 11:59:00 +0000 (14:59 +0300)
committerHugo Landau <hlandau@openssl.org>
Thu, 26 Oct 2023 14:43:08 +0000 (15:43 +0100)
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22470)

ssl/ssl_lib.c

index d2394ee0dbe6a666b93c36dcf5c03870d4143419..5314e1ec0dc7a5d29f3ed19364e647f9132bcbcd 100644 (file)
@@ -2906,8 +2906,9 @@ long SSL_ctrl(SSL *s, int cmd, long larg, void *parg)
 long ossl_ctrl_internal(SSL *s, int cmd, long larg, void *parg, int no_quic)
 {
     long l;
+    SSL_CONNECTION *sc = SSL_CONNECTION_FROM_SSL(s);
 
-    if (s == NULL)
+    if (sc == NULL)
         return 0;
 
     /*
@@ -2928,11 +2929,6 @@ long ossl_ctrl_internal(SSL *s, int cmd, long larg, void *parg, int no_quic)
     if (!no_quic && IS_QUIC(s))
         return s->method->ssl_ctrl(s, cmd, larg, parg);
 
-    SSL_CONNECTION *sc = SSL_CONNECTION_FROM_SSL(s);
-
-    if (sc == NULL)
-        return 0;
-
     switch (cmd) {
     case SSL_CTRL_GET_READ_AHEAD:
         return RECORD_LAYER_get_read_ahead(&sc->rlayer);