]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: ssl-sock: Silent error about NULL deref in ssl_sock_bind_verifycbk()
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 23 Nov 2022 08:27:13 +0000 (09:27 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 23 Nov 2022 08:27:14 +0000 (09:27 +0100)
In ssl_sock_bind_verifycbk(), when compiled without QUIC support, the
compiler may report an error during compilation about a possible NULL
dereference:

src/ssl_sock.c: In function ‘ssl_sock_bind_verifycbk’:
src/ssl_sock.c:1738:12: error: potential null pointer dereference [-Werror=null-dereference]
 1738 |         ctx->xprt_st |= SSL_SOCK_ST_FL_VERIFY_DONE;
      |         ~~~^~~~~~~~~

A BUG_ON() was addeded because it must never happen. But when compiled
without DEBUG_STRICT, there is nothing to help the compiler. Thus
ALREADY_CHECKED() macro is used. The ssl-sock context and the bind config
are concerned.

This patch must be backported to 2.6.

src/ssl_sock.c

index 2a4d64429a5efd3078cbb5ddee81eb8500d4826b..ad40b75ceb2b16976d9aa9448729ab15fa802724 100644 (file)
@@ -1734,6 +1734,8 @@ int ssl_sock_bind_verifycbk(int ok, X509_STORE_CTX *x_store)
 #endif
 
        BUG_ON(!ctx || !bind_conf);
+       ALREADY_CHECKED(ctx);
+       ALREADY_CHECKED(bind_conf);
 
        ctx->xprt_st |= SSL_SOCK_ST_FL_VERIFY_DONE;