From bab358badfc0f47a33df2d100bcda45ea3b125b4 Mon Sep 17 00:00:00 2001 From: Olivier Houchard Date: Wed, 2 Dec 2026 15:30:37 +0100 Subject: [PATCH] BUG/MEDIUM: flt-decomp: accept an empty payload Some servers announce a content-encoding on a message with an empty payload, e.g. a chunked response with only the last chunk. No data are passed to the decoder in this case, so it never reports the end of the compressed stream: the end of the message was held forever, and since truncated payloads are detected, it was reported as an error. Now the filter remembers when payload data were received. When the end of the payload is reached without any, there is nothing to decompress and the decompression is considered as finished, so the empty message is forwarded. The filter was introduced in 3.5-dev6, so no backport is needed. --- src/flt_decomp.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/flt_decomp.c b/src/flt_decomp.c index 3fe8d51b8..46c6099f9 100644 --- a/src/flt_decomp.c +++ b/src/flt_decomp.c @@ -34,6 +34,7 @@ #define DECOMP_STATE_PROCESSING 0x01 #define DECOMP_STATE_EOM_SEEN 0x02 +#define DECOMP_STATE_DATA_SEEN 0x04 /* some payload data were received */ const char *decomp_req_flt_id = "decomp-req filter"; const char *decomp_res_flt_id = "decomp-res filter"; @@ -268,6 +269,7 @@ static int decomp_stream_blk(struct stream *s, struct filter *f, struct channel case HTX_BLK_UNUSED: goto next; case HTX_BLK_DATA: + st->flags |= DECOMP_STATE_DATA_SEEN; if (blk->flags & HTX_BLK_FL_EOM) { blk->flags &= ~HTX_BLK_FL_EOM; st->flags |= DECOMP_STATE_EOM_SEEN; @@ -349,6 +351,14 @@ static int decomp_stream_blk(struct stream *s, struct filter *f, struct channel /* there is still pending data that we need to drain */ break; } + if (!(st->flags & DECOMP_STATE_DATA_SEEN)) { + /* The end of the payload is reached without any + * data. There is nothing to decompress, so it is + * an empty payload, not a truncated one. The + * decompression is finished. + */ + st->decomp_ctx->flags |= DECOMP_CTX_FL_DONE; + } if (!(st->decomp_ctx->flags & DECOMP_CTX_FL_DONE)) { char *data = ""; -- 2.47.3