]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: mux-h1: Dup connection/upgrade value to parse it when making headers
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 29 May 2026 14:26:29 +0000 (16:26 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 1 Jun 2026 07:59:33 +0000 (09:59 +0200)
When message headers are formatted, the connection and upgrade header values
are parsed to be sanitized and to fill H1M flags. The values are modified in
place without changing the HTX message information accordingly (the block
info and the HTX info). It could be an issue if the output buffer is full
and the header cannot be formatted. Because the formatting can be stopped
with a HTX message in hazardous state.

It should be quite difficult to trigger this issue. But now, a copy of the
value is performed before parsing it. So only the copy will be altered,
leaving the HTX message in a safe state.

This patch must be backported to all stable versions.

src/mux_h1.c

index 1ad6260fe6b7ef107b981a64a826b21c280863b3..55625014499c2cb2c8ac008812ec61a87968f042 100644 (file)
@@ -2708,11 +2708,17 @@ static size_t h1_make_headers(struct h1s *h1s, struct h1m *h1m, struct htx *htx,
                                h1s->flags |= H1S_F_HAVE_CLEN;
                        }
                        else if (isteq(n, ist("connection"))) {
+                               /* copy the value because it can be modified, but the HTX blocks will not */
+                               memcpy(trash.area, v.ptr, v.len);
+                               v.ptr = trash.area;
                                h1_parse_connection_header(h1m, &v);
                                if (!v.len)
                                        goto nextblk;
                        }
                        else if (isteq(n, ist("upgrade"))) {
+                               /* copy the value because it can be modified, but the HTX blocks will not */
+                               memcpy(trash.area, v.ptr, v.len);
+                               v.ptr = trash.area;
                                h1_parse_upgrade_header(h1m, &v);
                                if (!v.len)
                                        goto nextblk;