]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: ssl: fix build in release mode
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 24 Jan 2022 10:04:05 +0000 (11:04 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 24 Jan 2022 10:15:48 +0000 (11:15 +0100)
Fix potential null pointer dereference. In fact, this case is not
possible, only a mistake in SSL ex-data initialization may cause it :
either connection is set or quic_conn, which allows to retrieve
the bind_conf.

A BUG_ON was already present but this does not cover release build.

src/ssl_sock.c

index 1aa46d74f723cea804c467f46c22f5065d215141..572fa76476fbc12d4532fe7e0896870bf6e4c26f 100644 (file)
@@ -1537,7 +1537,12 @@ void ssl_sock_infocbk(const SSL *ssl, int where, int ret)
        else if (qc)
                ctx = qc->xprt_ctx;
 #endif /* USE_QUIC */
-       BUG_ON(!ctx);
+
+       if (!ctx) {
+               /* must never happen */
+               ABORT_NOW();
+               return;
+       }
 
 #ifndef SSL_OP_NO_RENEGOTIATION
        /* Please note that BoringSSL defines this macro to zero so don't
@@ -2488,7 +2493,12 @@ int ssl_sock_switchctx_cbk(SSL *ssl, int *al, void *arg)
        else if (qc)
                s = qc->li->bind_conf;
 #endif /* USE_QUIC */
-       BUG_ON(!s);
+
+       if (!s) {
+               /* must never happen */
+               ABORT_NOW();
+               return 0;
+       }
 
 #ifdef USE_QUIC
        if (qc) {