]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MINOR: h1-htx: don't remove data already queued on a chunk parsing error
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 3 Dec 2026 14:53:00 +0000 (15:53 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 4 Dec 2026 13:53:05 +0000 (14:53 +0100)
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.

src/h1_htx.c

index 0698a95dcf7ca28a7e1d6b72288df94c74047e14..84f1e3b9d9a36c5bcf482effd1ea99849a8ec471 100644 (file)
@@ -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;