From: Amaury Denoyelle Date: Tue, 24 Nov 2026 09:29:04 +0000 (+0100) Subject: BUG/MINOR: h3: support unknown frames of any length X-Git-Url: https://git.kaiwu.me/http/ngx_http_proxy_module.html?a=commitdiff_plain;h=90684f118b0b21e313d504e89daac109e73b05c9;p=haproxy.git BUG/MINOR: h3: support unknown frames of any length Extension frames, when unknown, must be ignored as required by RFC 9114. This is already implemented in the HTTP/3 parser. Improve the handling of extension frames so that payloads larger than the buffer size are allowed. This only requires relaxing the frame type test for streaming parsing. The re-entrancy mechanism relying on the and members is already implemented for DATA handling. Previously, such frames caused a connection closure with the error code H3_EXCESSIVE_LOAD. This must be backported up to 2.6 after a period of observation. --- diff --git a/src/h3.c b/src/h3.c index 1b8185425..50eeb64fc 100644 --- a/src/h3.c +++ b/src/h3.c @@ -500,6 +500,13 @@ static int h3_check_frame_valid(struct h3c *h3c, struct qcs *qcs, uint64_t ftype return ret; } +/* Returns true if is in the HTTP/3 frame type registry. */ +static int h3_frame_is_known(const uint64_t type) +{ + /* Reserved extension frame types of the format 0x1f * N + 0x21 are considered as unknown as well. */ + return type <= H3_FT_RESERVED_4 || type == H3_FT_MAX_PUSH_ID; +} + /* Check from stream that length of all DATA frames does not exceed with * a previously parsed content-length header. must be set for the last * data of the stream so that length of DATA frames must be equal to the @@ -2182,11 +2189,11 @@ static ssize_t h3_rcv_buf(struct qcs *qcs, struct buffer *b, int fin) flen = h3s->demux_frame_len; ftype = h3s->demux_frame_type; - /* Current HTTP/3 parser can currently only parse fully - * received frames. The only exception is for DATA frames as - * they can frequently be larger than bufsize. + /* Most HTTP/3 registered frames can only be parsed once fully + * received. Only DATA and extension frames can be parsed in a + * streaming manner. */ - if (ftype != H3_FT_DATA) { + if (ftype != H3_FT_DATA && h3_frame_is_known(ftype)) { /* Reject frames bigger than bufsize. * * TODO HEADERS should in complement be limited with H3 @@ -2409,8 +2416,7 @@ static ssize_t h3_rcv_buf(struct qcs *qcs, struct buffer *b, int fin) } } - if (ret >= 0) - ret = flen; + ret = MIN(flen, b_data(b)); break; }