]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MINOR: stats: never add an empty DATA block in the HTX message
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 30 Nov 2026 13:28:10 +0000 (14:28 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 30 Nov 2026 15:03:42 +0000 (16:03 +0100)
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.

src/stats.c

index b669e4167ff62a6edfc30fcbbf5942838db2ac64..c2a715fe8677c57d8065a7ea032d14d9287ce907 100644 (file)
@@ -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;
                }