BUG/MAJOR: mux-h1: Properly handle wrapping on obuf when dumping the first-line
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 21 Nov 2024 21:01:12 +0000 (22:01 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 22 Nov 2024 14:50:23 +0000 (15:50 +0100)
commit27dd4f4efe1cd4d250b8de7831e711fc37ceee68
treeb165bde8653858a130ea80f95bc48fecd2a0808f
parentcd587f2b488550dd33c79d91144b0d19ef1127ae
BUG/MAJOR: mux-h1: Properly handle wrapping on obuf when dumping the first-line

The formatting of the first-line, for a request or a response, does not
properly handle the wrapping of the output buffer. This may lead to a data
corruption for the current response or eventually for the previous one.

Utility functions used to format the first-line of the request or the
response rely on the chunk API. So it is not expected to pass a buffer that
wraps. Unfortunatly, because of a change performed during the 2.9 dev cycle,
the output buffer was direclty used instead of a non-wrapping buffer created
from it with b_make() function. It is not an issue for the request because
its start-line is always the first block formatted in the output buffer. But
for the response, the output may be not empty and may wrap. In that case,
the response start-line is dumped at a random position in the buffer,
corrupting data. AFAIK, it is only an issue if the HTTP request pipelining
is used.

To fix the issue, we now take care to create a non-wapping buffer from the
output buffer.

This patch should fix issues #2779 and #2996. It must be backported as far as
2.9.

(cherry picked from commit b150ae46dd97caa5050d8abefc1d9b619ab5ab9a)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
src/h1_htx.c
src/mux_h1.c