]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: h1: Fail to parse empty transfer coding names
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 9 Jul 2024 06:15:14 +0000 (08:15 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 10 Jul 2024 08:52:20 +0000 (10:52 +0200)
Empty transfer coding names, inside a comma-separated list, are already
rejected. But it is only by chance. Today, it is detected as an unknown
coding names (not "chunked" concretly). Then, it is handled by the H1
multiplexer as an error and a 422-Unprocessable-Content response is
returned.

So, the error is properly detected in this case, but it is not accurate. A
400-bad-request response must be returned instead. Then, it is better to
catch the error during the header parsing. It is the purpose of this patch.

This patch should be backported as far as 2.6.

src/h1.c

index bbaa2f67cea907887a24631188fd8730233ab88c..ff3f5ae9aa4f498f54596f3761afa2e7acc4c255 100644 (file)
--- a/src/h1.c
+++ b/src/h1.c
@@ -147,7 +147,12 @@ int h1_parse_xfer_enc_header(struct h1m *h1m, struct ist value)
                        word.len--;
 
                h1m->flags &= ~H1_MF_CHNK;
-               if (isteqi(word, ist("chunked"))) {
+
+               /* empty values are forbidden */
+               if (!word.len)
+                       goto fail;
+
+               else if (isteqi(word, ist("chunked"))) {
                        if (h1m->flags & H1_MF_TE_CHUNKED) {
                                /* cf RFC7230#3.3.1 : A sender MUST NOT apply
                                 * chunked more than once to a message body