]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MEDIUM: http-client: Don't use the httpclient context if it was released
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 16 Sep 2026 07:13:30 +0000 (09:13 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 18 Sep 2026 14:50:30 +0000 (16:50 +0200)
The I/O handler of the http-client applet may be called after the applet
release. In this case, the httpclient context is no longer available and the
I/O handler must not use it. It is properly handled at the beginning of the
function. However, the code added at the end, on the "out" label, to stop
the data reception is evaluated in all cases, including when the httpclient
context is NULL. It leads to a NULL-pointer dereference.

So, now, <hc> is tested first.

This patch must be backported as far as 3.3 with commit b24260ec9
("BUG/MEDIUM: http-client: Only consume input buffer when hc one is empty").

src/http_client.c

index 96d55ee803919b90c4f1c333fcb6b16eeef840bb..d2b75309c1bbbdad6dd4b6d941370f745028946e 100644 (file)
@@ -879,7 +879,7 @@ void httpclient_applet_io_handler(struct appctx *appctx)
        }
 
 out:
-       if (appctx->st0 != HTTPCLIENT_S_RES_END && !b_is_null(&hc->res.buf)) {
+       if (hc && appctx->st0 != HTTPCLIENT_S_RES_END && !b_is_null(&hc->res.buf)) {
                /* Don't accept more data while the httpclient response buffer is not empty */
                applet_wont_consume(appctx);
        }