]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MEDIUM: flt-decomp: report an error on a truncated payload
authorOlivier Houchard <ohouchard@haproxy.com>
Wed, 2 Dec 2026 14:11:12 +0000 (15:11 +0100)
committerOlivier Houchard <cognet@ci0.org>
Wed, 2 Dec 2026 14:33:02 +0000 (15:33 +0100)
When the compressed payload is truncated while the HTTP message itself
is complete, the decoder never reports the end of the stream and no
error was raised. The end of the message was held forever: no timeout
applied, the stream was only released when the client left, and
depending on the payload size a thread could spin meanwhile.

Now, once the whole message was received and all the input was consumed,
if flushing the decompression state produces nothing while the
decompression is still not finished, an error is returned, as for a
corrupted payload. The filter was introduced in 3.5-dev6, so no backport
is needed.

src/flt_decomp.c

index aca1fd97bc26d986038c218f0ff9c5374ba3fb33..2a781ceb2d833bc4af7cf099bdfedf3498c357e5 100644 (file)
@@ -422,6 +422,19 @@ static int decomp_stream_blk(struct stream *s, struct filter *f, struct channel
                        if (ret == -1)
                                goto error;
 
+                       /* The whole message was received and all the input was
+                        * consumed, but the decompression state was flushed
+                        * with no data produced and the decompression is still
+                        * not finished. It means the compressed payload was
+                        * truncated. Nothing more will come, so it is an
+                        * error. Otherwise, the end of the message would be
+                        * held forever.
+                        */
+                       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))
+                               goto error;
+
                        ret = decomp_stream_blk_drain(s, f, chn, NULL, NULL, 0);
                        total += ret;
                }