]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MINOR: http-fetch: make http_first_req() check for HTTP first
authorWilly Tarreau <w@1wt.eu>
Mon, 11 May 2026 12:58:45 +0000 (14:58 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 11 May 2026 14:04:19 +0000 (16:04 +0200)
smp_fetch_http_first_req() reads ->txn.http->flags without first
checking if txn.http is properly allocated. In theory if called from
the wrong context it could crash, even though tests where it's called
from "tcp-request content" don't seem to have any effect. Let's fix
it regardless, at least to dissipate the doubt. It can be backported
everywhere.

src/http_fetch.c

index b030509d5ef054f762d6248a6b064a954d73c8f6..3a7ca3c5c8ddd4bf6032f806a209c744acd81240 100644 (file)
@@ -1355,7 +1355,7 @@ static int smp_fetch_proto_http(const struct arg *args, struct sample *smp, cons
 /* return a valid test if the current request is the first one on the connection */
 static int smp_fetch_http_first_req(const struct arg *args, struct sample *smp, const char *kw, void *private)
 {
-       if (!smp->strm)
+       if (!smp->strm || !smp->strm->txn.http)
                return 0;
 
        smp->data.type = SMP_T_BOOL;