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.
This commit is contained in:
Christopher Faulet 2024-11-20 16:02:53 +01:00
parent 349954601f
commit e415e3cb7a
1 changed files with 3 additions and 3 deletions

View File

@ -6123,7 +6123,7 @@ static int h2_frt_transfer_data(struct h2s *h2s)
*/
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;