[PATCH 2/2] BUG/MINOR: http-htx: Just warn if payload of an errorfile doesn't match...
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 6 Nov 2020 08:33:36 +0000 (09:33 +0100)
committerVincent Bernat <bernat@debian.org>
Wed, 11 Nov 2020 15:21:12 +0000 (15:21 +0000)
During startup, when an errorfile is parsed, if its payload does not match the
announced content-length, an error is triggered. This change was introduced in
the 2.3, which is ok. But for a stable release it may be seen as a
regression. Thus, now a warning is emitted, instead of an error. And the
content-length header is updated with the real payload length.

This patch depends on 58f55acf4e ("MINOR: http-htx: Add understandable errors
for the errorfiles parsing"). Both must be backported as far as 2.0. This bug
only exists in the 2.2, 2.1 and 2.0. Thus, there is no upstream commit ID for
this patch.

Gbp-Pq: Name 0002-BUG-MINOR-http-htx-Just-warn-if-payload-of-an-errorf.patch

src/http_htx.c

index 60c4a7a73383914e14ec606a9ce4e5a825b1f6f0..51dbf44a6d3fbe66b292b80381620dcd34068aa1 100644 (file)
@@ -967,9 +967,17 @@ int http_str_to_htx(struct buffer *buf, struct ist raw, char **errmsg)
                goto error;
        }
        if ((flags & HTX_SL_F_CLEN) && h1m.body_len != (raw.len - ret)) {
-               memprintf(errmsg, "payload size does not match the announced content-length (%lu != %lu)",
+               struct ist clen = ist(ultoa(raw.len - ret));
+               int i;
+
+               memprintf(errmsg, "payload size does not match the announced content-length (%lu != %lu)."
+                         " C-L header is updated accordingly but it should be fixed to avoid any errors on future versions.",
                          (raw.len - ret), h1m.body_len);
-               goto error;
+
+               for (i = 0; hdrs[i].n.len; i++) {
+                       if (isteqi(hdrs[i].n, ist("content-length")))
+                               hdrs[i].v = clen;
+               }
        }
 
        htx = htx_from_buf(buf);