]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MINOR: flt-decomp: don't lose emitted data on a truncated payload
authorOlivier Houchard <ohouchard@haproxy.com>
Wed, 2 Dec 2026 14:30:38 +0000 (15:30 +0100)
committerOlivier Houchard <cognet@ci0.org>
Wed, 2 Dec 2026 14:33:02 +0000 (15:33 +0100)
When a truncated payload was detected, the error was reported
immediately, and the decompressed data emitted during the same call were
lost with it: for a 30kB response missing the end of its gzip stream,
only 15.8kB were delivered before the abort.

Now the error is only reported when nothing was emitted during the call
and the channel has no more outgoing data. Until then, the filter waits
to be called again once the output is drained. The filter was introduced
in 3.5-dev6, so no backport is needed.

src/flt_decomp.c

index 46c6099f96221cfbe280ac20bc9514b5918c7c1f..7cbeca256083cf5d4a8c01f4d11cc8167b003554 100644 (file)
@@ -446,10 +446,16 @@ static int decomp_stream_blk(struct stream *s, struct filter *f, struct channel
                         * truncated. Nothing more will come, so it is an
                         * error. Otherwise, the end of the message would be
                         * held forever.
+                        *
+                        * But the error is only reported once all forwarded
+                        * data were sent, because they would be lost
+                        * otherwise. Until then, we wait to be called again
+                        * when the output is drained.
                         */
                        if (!blk && ((st->flags & DECOMP_STATE_EOM_SEEN) || htx_msg_ended(htx)) &&
                            !st->decomp_ctx->drain_len &&
-                           !(st->decomp_ctx->flags & DECOMP_CTX_FL_DONE))
+                           !(st->decomp_ctx->flags & DECOMP_CTX_FL_DONE) &&
+                           !total && !co_data(chn))
                                goto error;
 
                        ret = decomp_stream_blk_drain(s, f, chn, NULL, NULL, 0);