From: Christopher Faulet Date: Thu, 3 Dec 2026 14:53:00 +0000 (+0100) Subject: BUG/MINOR: h1-htx: don't remove data already queued on a chunk parsing error X-Git-Url: https://git.kaiwu.me/web/ngx_http_fastcgi_module.html?a=commitdiff_plain;h=70d0376713276d3bb4fee280994c38f491755add;p=haproxy.git BUG/MINOR: h1-htx: don't remove data already queued on a chunk parsing error In h1_parse_full_contig_chunks(), the HTX DATA block used to copy the chunks is reserved with htx_reserve_max_data(). It may be a new block or the last DATA block, extended. On parsing error, since the commit 4af4feed3 ("BUG/MEDIUM: h1_htx: Remove reverved block on error during contig chunks parsing"), this block was removed. But when it was an existing block, data already queued were removed with it. If these data were already scheduled for output, the channel's output count then exceeded the data present in the buffer. Now, on parsing error, the block is only removed if it was created by this call. Otherwise, it is restored to its previous size. This patch must be backported with the commit above, as far as 2.6. --- diff --git a/src/h1_htx.c b/src/h1_htx.c index 0698a95dc..84f1e3b9d 100644 --- a/src/h1_htx.c +++ b/src/h1_htx.c @@ -875,7 +875,14 @@ static size_t h1_parse_full_contig_chunks(struct h1m *h1m, struct htx **dsthtx, parsing_error: (*dsthtx)->flags |= HTX_FL_PARSING_ERROR; - htx_remove_blk(*dsthtx, htxret.blk); + /* Restore the HTX block to its previous size or remove it if it was + * created here. The reserved block may be an existing DATA block that + * was extended. In this case, data already present must be preserved. + */ + if (!htxret.ret) + htx_remove_blk(*dsthtx, htxret.blk); + else + htx_change_blk_value_len(*dsthtx, htxret.blk, htxret.ret); h1m->err_state = h1m->state; h1m->err_pos = ofs + end + ridx - start; return 0;