From: Olivier Houchard Date: Wed, 2 Dec 2026 14:11:12 +0000 (+0100) Subject: BUG/MEDIUM: flt-decomp: don't forward trailers before pending data X-Git-Tag: v3.5.0~11 X-Git-Url: https://git.kaiwu.me/web/%7Bsubstring-before(@doc,%20'.xml')%7D.html?a=commitdiff_plain;h=92e792fa20c37568023e67349c006fb0f1d813c4;p=haproxy.git BUG/MEDIUM: flt-decomp: don't forward trailers before pending data In decomp_stream_blk(), only the EOT block was held while decompressed data were still pending. TLR blocks, and the NOOP block carrying the EOM since commit 221c40bbf ("MINOR: htx: Add a noop block to carry the EOM flag on an empty message"), were forwarded immediately. When the decompressed data did not all fit in the buffer, the trailers and the end of the message were thus sent before the remaining data: a chunked gzip response of 30kB with a trailer was delivered as a complete message of 15.8kB. In the request direction, it led to a 500 with "IH--". Now these blocks are handled like the EOT block. In addition, when the decompression state is flushed on such a block and the decompression is finished with nothing left to emit, the block is now counted as forwarded, otherwise the following ones would be counted while this one is not. The filter was introduced in 3.5-dev6 by commit f0710d808 ("MEDIUM: flt-decomp: implement decomp-req and decomp-res filters"), so no backport is needed. --- diff --git a/src/flt_decomp.c b/src/flt_decomp.c index 7a21d3b83..aca1fd97b 100644 --- a/src/flt_decomp.c +++ b/src/flt_decomp.c @@ -332,6 +332,11 @@ static int decomp_stream_blk(struct stream *s, struct filter *f, struct channel } break; + case HTX_BLK_NOOP: + if (!(blk->flags & HTX_BLK_FL_EOM)) + goto consume; + __fallthrough; + case HTX_BLK_TLR: case HTX_BLK_EOT: if (st->decomp_ctx->drain_len) { /* there is still pending data that we need to drain */ @@ -348,10 +353,18 @@ static int decomp_stream_blk(struct stream *s, struct filter *f, struct channel if (ret == -1) goto error; - break; /* if decomp_ctx->drain_len is set it will be taken - * care of - */ - + /* If some data are pending or if the decompression + * is not finished, this block and the following + * ones must not be forwarded yet. Pending data will + * be drained later, before this block. Otherwise, + * the decompression is finished with no data left, + * so this block must be counted as forwarded. It + * must not be skipped while the following ones are + * counted. + */ + if (st->decomp_ctx->drain_len || + !(st->decomp_ctx->flags & DECOMP_CTX_FL_DONE)) + break; } /* don't forget some out of payload data such as EOT count as forwarded @@ -362,6 +375,7 @@ static int decomp_stream_blk(struct stream *s, struct filter *f, struct channel break; default: + consume: /* nothing to do with that, just forward */ total += htx_get_blksz(blk); break;