]> git.kaiwu.me - haproxy.git/commitdiff
MINOR: mux-h1: ignore the trailers when formatting a non-chunked HTX message
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 1 Dec 2026 13:48:28 +0000 (14:48 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 3 Dec 2026 12:41:06 +0000 (13:41 +0100)
h1_format_htx_msg() documents that the trailers are silently ignored when
the message is not chunked, but the HTX_BLK_TLR blocks were formatted like
headers in that case. A trailer name/value pair would then be emitted after
the body of a non-chunked message, without any framing, corrupting the
output.

No caller can currently reach this (the only caller formats fixed error
messages, which have no trailers), so this is a latent hardening of the
documented contract.

src/h1_htx.c

index 18501e2f58b6b0d2d31947a3a42f42d1be1fcdcf..d4d2df56af49858752cd3d6412a0d0bfa29d6004 100644 (file)
@@ -1280,7 +1280,10 @@ int h1_format_htx_msg(const struct htx *htx, struct buffer *outbuf, struct h1_hd
                                goto full;
                }
                else if (type == HTX_BLK_TLR) {
-                       if ((flags & HTX_SL_F_CHNK) && has_eod == 0 && !b_putblk(outbuf, "0\r\n", 3))
+                       /* Trailers are ignored if the message is not chunked */
+                       if (!(flags & HTX_SL_F_CHNK))
+                               continue;
+                       if (has_eod == 0 && !b_putblk(outbuf, "0\r\n", 3))
                                goto full;
                        has_eod = 1;
                        n = htx_get_blk_name(htx, blk);