]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: ssl: Potential NULL deref in trace macro
authorRemi Tricot-Le Breton <rlebreton@haproxy.com>
Wed, 10 Sep 2025 08:13:22 +0000 (10:13 +0200)
committerWilliam Lallemand <wlallemand@haproxy.com>
Thu, 11 Sep 2025 12:31:32 +0000 (14:31 +0200)
'ctx' might be NULL when we exit 'ssl_sock_handshake', it can't be
dereferenced without check in the trace macro.

This was found by Coverity andraised in GitHub #3113.
This patch should be backported up to 3.2.

src/ssl_sock.c

index b973a3967ee9f73835a413514bedf525072ba81e..c6bfcf5e330ae8f4da603913713268f9f95ea333 100644 (file)
@@ -5909,7 +5909,7 @@ reneg_ok:
        if (!conn->err_code)
                conn->err_code = CO_ER_SSL_HANDSHAKE;
 
-       TRACE_ERROR("handshake error", SSL_EV_CONN_HNDSHK|SSL_EV_CONN_ERR, conn, ctx->ssl, &conn->err_code, &ctx->error_code);
+       TRACE_ERROR("handshake error", SSL_EV_CONN_HNDSHK|SSL_EV_CONN_ERR, conn, ctx->ssl, &conn->err_code, (ctx ? &ctx->error_code : NULL));
        return 0;
 }