BUG/MEDIUM: cache/stats: Wait to have the request before sending the response
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 16 Sep 2024 17:17:33 +0000 (19:17 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 17 Sep 2024 07:29:23 +0000 (09:29 +0200)
commitfaf9feac31da865fca309485cfb27ed52b776087
tree5c8ba43b38ab8e05be0a0f5ffe2e3bb3db503f61
parent3b75ca846ceb371db10eed5ec2c5bd02273ffa64
BUG/MEDIUM: cache/stats: Wait to have the request before sending the response

It seems obvious. On a classical workflow, the request headers analysis is
finished when these applets are woken up for the first time. So they don't
take care to really have the request to start to process it and to send the
response. But with a filter, it is possible to stop the request analysis
after the applet creation.

If this happens for the stats applet, this leads to a crash because we
retrieve the request start-line without checking if it is available. For the
cache applet, the response is just immediatly sent. And here it is a problem
if the compression is enabled. In that case too, this may lead to a crash
because the compression may be enabled but not initialized.

For a true server, there is no issue because the connection cannot be
established. The server is chosen only after the request analysis. The issue
with applets is that once created, an applet is quickly switched to the
established state. So it is probably a point that must be carefully reviewed
and probably reworked.

In the mean time, as a fix, in the cache and the stats applet, we just take
care to have the request before sending the response. This will do the
trick.

The patch must be backported as far as 2.6. On 2.6, the patch must be adapted.

(cherry picked from commit afc50f2445e02c778095cf4d7392c505f5af5278)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
src/cache.c
src/stats-html.c