]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MINOR: flt-http-comp: Don't read next block to detect end of data
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 26 Aug 2026 08:32:59 +0000 (10:32 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 26 Aug 2026 12:26:56 +0000 (14:26 +0200)
During the compression, on a DATA block, the next blocks was tested to know
if the end of data was reached. However, it is not valid to do so because a
prior filter may have limited the data forwarding to the current block to
inject more DATA blocks later for instance. Because of this bug, we could
detect the end of the payload too early, hijacking this way processing of
prior filters.

This test was added as an optimization, to save a loop on the HTX
message. So it can be safely removed.

For now, it is not possible to hit the bug with in-house filters. But a lua
filter modifiying the payload could trigger it. And it will be an issue if
the compression filter is chained with the decompression one (once
added). So let's fix it now.

This patch must be backported to all supported versions.

src/flt_http_comp.c

index 7f2567feb9853620031a02303f52a7b326f6d6ce..ea328dd918ed04ebf4823bb5563b234afc893848 100644 (file)
@@ -295,11 +295,10 @@ comp_http_payload(struct stream *s, struct filter *filter, struct http_msg *msg,
                        msg->chn->flags |= CF_WAKE_WRITE;
                        goto end;
                }
-
                switch (type) {
                        case HTX_BLK_DATA:
                                /* it is the last data block */
-                               last = ((!next && (htx->flags & HTX_FL_EOM)) || (next && htx_get_blk_type(next) != HTX_BLK_DATA));
+                               last = (!next && (htx->flags & HTX_FL_EOM));
                                v = htx_get_blk_value(htx, blk);
                                v = istadv(v, offset);
                                if (v.len > len) {