From: Christopher Faulet Date: Mon, 30 Nov 2026 13:28:10 +0000 (+0100) Subject: BUG/MINOR: stats: never add an empty DATA block in the HTX message X-Git-Url: https://git.kaiwu.me/http/%22../doc/static/%7B@url%7D?a=commitdiff_plain;h=55d77d18a88446f9797b10852396dd470dedc8db;p=haproxy.git BUG/MINOR: stats: never add an empty DATA block in the HTX message In stats_putchk(), the current chunk is added to the HTX message with htx_add_data_atonce(), without checking the chunk is not empty. If the chunk is empty when the function is called, a zero-sized DATA block is added to the HTX message. For a chunked response, mux-h1 would emit a zero-sized chunk, i.e. the last-chunk, prematurely ending the message for the client and making it interpret any remaining data as a new message (response splitting). No way was found to make a stats dump produce an empty chunk, so this is a latent bug, but the HTX API is not supposed to accept empty data blocks and the consequence would be dramatic. So, let's simply skip the add when the chunk is empty. It also avoids stats_putchk() to wrongly report a full buffer once the HTX API starts to refuse empty data. This may be backported if desired. --- diff --git a/src/stats.c b/src/stats.c index b669e4167..c2a715fe8 100644 --- a/src/stats.c +++ b/src/stats.c @@ -242,7 +242,7 @@ int stats_putchk(struct appctx *appctx, struct buffer *buf, struct htx *htx) applet_fl_set(appctx, APPCTX_FL_OUTBLK_FULL); return 0; } - if (!htx_add_data_atonce(htx, ist2(b_orig(chk), b_data(chk)))) { + if (b_data(chk) && !htx_add_data_atonce(htx, ist2(b_orig(chk), b_data(chk)))) { applet_fl_set(appctx, APPCTX_FL_OUTBLK_FULL); return 0; }