BUG/MINOR: h3: ensure that invalid status code are not encoded (FE side)
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 15 Jul 2025 16:15:36 +0000 (18:15 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 17 Oct 2025 09:19:01 +0000 (11:19 +0200)
commit8d4b3efb131477d73aed99bf7caac6c668760817
treeb04dbcba90be1b5f1dd79c51800ff816c95bff00
parentaac3b445bd62d5f365756a906911eee9277d8a42
BUG/MINOR: h3: ensure that invalid status code are not encoded (FE side)

On frontend side, H3 layer transcodes HTX status code into HTTP/3
HEADERS frame. This is done by calling qpack_encode_int_status().

Prior to this patch, the latter function was also responsible to reject
an invalid value, which guarantee that only valid codes are encoded
(between 100 and 999 values). However, this is not practical as it is
impossible to differentiate between an invalid code error and a buffer
room exhaustation.

Changes this so that now HTTP/3 layer first ensures that HTX code is
valid. The stream is closed with H3_INTERNAL_ERROR if invalid value is
present. Thus, qpack_encode_int_status() will only report an error due
to buffer room exhaustion. If a small buffer is used, a standard buffer
will be reallocated which should be sufficient to encode the response.

The impact of this bug is minimal. Its main benefit is code clarity,
while also removing an unnecessary realloc when confronting with an
invalid HTTP code.

This should be backported at least up to 3.1. Prior to it, smallbuf
mechanism isn't present, hence the impact of this patch is less
important. However, it may still be backported to older versions, which
should facilitate picking patches for HTTP 1xx interim response support.

(cherry picked from commit d8b34459b52027d0621ebb0ac146fa277ab8e2ba)
Signed-off-by: Amaury Denoyelle <adenoyelle@haproxy.com>
(cherry picked from commit eb73c1d08783c49581876c9e95bad0b5a24fd6fc)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 53e0aec26e6636b8a4ad50112e9ddea2f823f015)
Signed-off-by: Amaury Denoyelle <adenoyelle@haproxy.com>
src/h3.c
src/qpack-enc.c