From cf68c1918a15aa1afae7fb5fc6472df7dedaa4f9 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Mon, 30 Jan 2023 08:26:09 +0100 Subject: [PATCH] BUG/MINOR: mux-h2: Fix possible null pointer deref on h2c in _h2_trace_header() As reported by Coverity, this function may be called with no h2c. Thus, the pointer must always be checked before any access. One test was missing in TRACE_PRINTF_LOC(). This patch should fix the issue #2015. No backport needed, except if the commit 11e8a8c2a ("MEDIUM: mux-h2/trace: add tracing support for headers") is backported. (cherry picked from commit c254516c5347052041630f9769ca1cd155d4f1d0) Signed-off-by: Willy Tarreau (cherry picked from commit b899aabd7aa8cf1daff519169fab3993a952812f) Signed-off-by: Christopher Faulet --- src/mux_h2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mux_h2.c b/src/mux_h2.c index c5d6dca8b..0f7574dcc 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -1033,7 +1033,7 @@ void _h2_trace_header(const struct ist hn, const struct ist hv, chunk_appendf(&trash, " (... +%ld)", (long)(hv.len - v_ist.len)); TRACE_PRINTF_LOC(TRACE_LEVEL_USER, mask, trc_loc, func, - h2c->conn, 0, 0, 0, + (h2c ? h2c->conn : 0), 0, 0, 0, "%s%s%s %s: %s", c_str, s_str, (mask & H2_EV_TX_HDR) ? "sndh" : "rcvh", n_ist.ptr, v_ist.ptr);