BUG/MEDIUM: capture: capture.{req,res}.* crash without a stream
authorWilly Tarreau <w@1wt.eu>
Wed, 29 Apr 2020 09:44:54 +0000 (11:44 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 1 May 2020 10:21:16 +0000 (12:21 +0200)
commit9bec56b7734ea75c6f235bc3f6bf03569b9bf2c5
tree4c3d2c135a2c80ed9f179724dd20c4922b04bc2b
parent909523621f634a8d8a1e70a3a5024238dc313b0d
BUG/MEDIUM: capture: capture.{req,res}.* crash without a stream

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 capture.req.hdr, capture.res.hdr, capture.req.method, capture.req.uri,
capture.req.ver and capture.res.ver sample fetches used to assume the
presence of a stream, which is not necessarily the case (especially after
the commit above) and would crash haproxy if incorrectly used. Let's make
sure they check for this stream.

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

(cherry picked from commit 0898c2d2f2c5ae043a443550992efd90ec18b2ab)
Signed-off-by: Willy Tarreau <w@1wt.eu>
src/http_fetch.c