From: Christopher Faulet Date: Thu, 15 Apr 2021 07:28:02 +0000 (+0200) Subject: BUG/MINOR: http-fetch: Make method smp safe if headers were already forwarded X-Git-Url: http://git.haproxy.org/?a=commitdiff_plain;h=d47ffe4449ca8623ec2cd3cb415a5dd6568dc837;p=haproxy-2.1.git BUG/MINOR: http-fetch: Make method smp safe if headers were already forwarded When method sample fetch is called, if an exotic method is found (HTTP_METH_OTHER), when smp_prefetch_htx() is called, we must be sure the start-line is still there. Otherwise, HAproxy may crash because of a NULL pointer dereference, for instance if the method sample fetch is used inside a unique-id format string. Indeed, the unique id may be generated when the log message is emitted. At this stage, the request channel is empty. This patch must be backported as far as 2.0. But the bug exists in all stable versions for the legacy HTTP mode too. Thus it must be adapted to the legacy HTTP mode and backported to all other stable versions. (cherry picked from commit 6f97a611c83d7135d77407f7327980994413b842) Signed-off-by: Christopher Faulet (cherry picked from commit 1edd927c3d9f2257e053e8a5c93e5edaa1f9e91b) Signed-off-by: Christopher Faulet (cherry picked from commit 2e4aaea20d10324c66d936ba8ce892c6bab4200e) Signed-off-by: Christopher Faulet --- diff --git a/src/http_fetch.c b/src/http_fetch.c index f256fad..a067001 100644 --- a/src/http_fetch.c +++ b/src/http_fetch.c @@ -327,7 +327,7 @@ static int smp_fetch_meth(const struct arg *args, struct sample *smp, const char return 0; } - htx = smp_prefetch_htx(smp, chn, 0); + htx = smp_prefetch_htx(smp, chn, 1); if (!htx) return 0;