]> git.kaiwu.me - haproxy.git/commit
BUG/MINOR: h1-htx: report the trailer parsing error position master
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 30 Nov 2026 15:31:05 +0000 (16:31 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 30 Nov 2026 15:32:07 +0000 (16:32 +0100)
commit311882d7d2fb65d81746f96706073d2bfd82cdf6
tree56489c1d9117c1d5656dad5b2d034b25fd164c69
parent6d19ea0a74ef8e116cdbbcb88cf82be3c138d17f
BUG/MINOR: h1-htx: report the trailer parsing error position

Trailer parsing uses a dedicated h1m (tlr_h1m) whose err_pos is relative to
the start of the trailers in the source buffer, i.e. to the offset passed
to h1_parse_msg_tlrs(). On a parsing error the main message's err_pos was
set to h1m->next, the chunk-parsing position, so the error snapshot taken
by h1_capture_bad_message() pointed to the wrong location.

h1_parse_msg_tlrs() now seeds tlr_h1m.err_pos with -1 or -2 depending on
the caller's leniency instead of copying h1m->err_pos. This way a stale
non-negative err_pos left over from a tolerated violation in the main
message headers can no longer suppress the trailer parser's capture (all
capture branches in h1_headers_to_hdr_list() are gated on err_pos == -1),
and it cannot be leaked back into the main message either.

On error, when the trailer parser pinpointed the faulty byte, the main
message's err_pos is now set to ofs + tlr_h1m.err_pos, i.e. the position
in the source buffer. Otherwise the previous behavior (h1m->next) is kept
as the fallback. This mirrors what h1_parse_msg_hdrs() already does for
headers via h1m->next, and makes mux_h1/mux_fcgi capture the correct
position for the H1_MSG_TRAILERS state.

No backport needed, this only affects error snapshots reporting.
src/h1_htx.c