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