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