From e415e3cb7aa1feaac3ed703687656e09dd464eb3 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Wed, 20 Nov 2024 16:02:53 +0100 Subject: [PATCH] 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. --- src/mux_h2.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mux_h2.c b/src/mux_h2.c index 131db2f77..c1c7f1a69 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -6123,7 +6123,7 @@ try_again: */ static size_t h2s_snd_fhdrs(struct h2s *h2s, struct htx *htx) { - struct http_hdr list[global.tune.max_http_hdr]; + struct http_hdr list[global.tune.max_http_hdr * 2]; struct h2c *h2c = h2s->h2c; struct htx_blk *blk; struct buffer outbuf; @@ -6388,7 +6388,7 @@ static size_t h2s_snd_fhdrs(struct h2s *h2s, struct htx *htx) */ static size_t h2s_snd_bhdrs(struct h2s *h2s, struct htx *htx) { - struct http_hdr list[global.tune.max_http_hdr]; + struct http_hdr list[global.tune.max_http_hdr * 2]; struct h2c *h2c = h2s->h2c; struct htx_blk *blk; struct buffer outbuf; @@ -7179,7 +7179,7 @@ static size_t h2s_skip_data(struct h2s *h2s, struct buffer *buf, size_t count) */ static size_t h2s_make_trailers(struct h2s *h2s, struct htx *htx) { - struct http_hdr list[global.tune.max_http_hdr]; + struct http_hdr list[global.tune.max_http_hdr * 2]; struct h2c *h2c = h2s->h2c; struct htx_blk *blk; struct buffer outbuf;