]> git.kaiwu.me - haproxy.git/commit
BUG/MEDIUM: h1-htx: don't stall on messages ending exactly at the buffer's end
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 7 Oct 2026 08:50:08 +0000 (10:50 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 16 Oct 2026 17:08:55 +0000 (19:08 +0200)
commited1be7ee8e8543b2d0dcccd7274f41fc8713383c
tree06ee8eb70302ffa202bc8128be9718ea6a3b8f77
parentca17c297d02a119f8f330e3c16083fcccdf6d199
BUG/MEDIUM: h1-htx: don't stall on messages ending exactly at the buffer's end

h1_parse_msg_hdrs() realigns the input buffer when its data wrap, then
passes b_tail() as the end of the area to parse. But when the data end
exactly at the end of the buffer's area (head + data == size), they do not
wrap so no realign is performed, while b_tail() wraps to the buffer's
origin, blocking parsing of headers. This can only happen with pipelined
requests.

Because of this issue, the parsing of headers can be blocked waiting for
more data and the http-request timeout can be reached, especially if it
happens exactly on the end of headers for a bodyless request.

In #3540, the same issue led to a 414 error returned on a valid request.

Parsing of trailers don't have the issue because it compares b_peek(ofs) to
b_tail(), but it misses the case of a full buffer whose head is not at the
beginning (start == end, without wrapping).

To fix both, the area is realigned only if the data really wrap, and the
end of the area to parse is computed with b_stop(), which points to the
byte following the end of the data, even when they end exactly at the
end of the buffer's area: b_stop() only wraps after the end of the area,
never to the buffer's origin, contrary to b_tail().

This bug exists since the H1 mux was introduced.

This patch should fix the issue #3540. It must be backported to all supported
versions.
src/h1_htx.c