]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: http: the "http_first_req" sample fetch could crash without a steeam
authorWilly Tarreau <w@1wt.eu>
Wed, 29 Apr 2020 09:52:13 +0000 (11:52 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 29 Apr 2020 09:55:36 +0000 (11:55 +0200)
Since commit 5f940703b3 ("MINOR: log: Don't depends on a stream to process
samples in log-format string") it has become quite obvious that a few sample
fetch functions and converters were still heavily dependent on the presence
of a stream without testing for it.

The http_first_req sample fetch function, if called without a stream, will
result in a crash.

This fix adds a check for the stream's existence, and should be backported
to all stable versions up to 1.6.

src/http_fetch.c

index 0d01b797e3f7ab18639eb7dc1bbcf3e006c95eae..11c1c5ab0264931c10ebec83db3960be6c116ab7 100644 (file)
@@ -1184,6 +1184,9 @@ 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)
+               return 0;
+
        smp->data.type = SMP_T_BOOL;
        smp->data.u.sint = !(smp->strm->txn->flags & TX_NOT_FIRST);
        return 1;