BUG/MEDIUM: mux-h2: Increase max number of headers when encoding HEADERS frames
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 20 Nov 2024 15:02:53 +0000 (16:02 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 22 Nov 2024 14:46:48 +0000 (15:46 +0100)
commite9ad14e73d9fa0f2bdffb841bb23fbe27ab5a4f1
tree64cff7d93f5557050be80cfe81f84266d7c4713e
parentca12dcec263cf8125160ed7981c4886913a9bd72
BUG/MEDIUM: mux-h2: Increase max number of headers when encoding HEADERS frames

When a HEADERS frame is encoded to be sent, the maximum number of headers
allowed in the frame is lower than on receiving path. This can lead to
report a sending error while the message was accepted. It could be
confusing.

In addition, the start-line is splitted into pseudo-headers and consummes
this way some header slots, increasing the difference between HEADERS frames
encoding and decoding. It is even more noticeable because when a HEADERS
frame is decoded, a margin is used to be able to handle splitted cookie
headers. Concretly, on decoding path, a limit of twice the maxumum number of
headers allowed in a message (tune.http.maxhdr * 2) is used. On encoding
path, the exact limit is used. It is not consistent.

Note that when a frame is decoded, we must use a larger limit because the
pseudo headers are reassembled in the start-line and must count for one. But
also because, most of time, the cookies are splitted into several headers
and are reassembled too.

To fix the issue, the same ratio is applied on sending path. A limit must be
defined because an dynamic allocation is not acceptable. Twice of the
configured limit should be good enough to support headers manipulation.

This patch should be backported to all stable versions.

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