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.
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);