]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: compression: Be sure to never compress more than a chunk at once
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 3 Feb 2026 06:54:11 +0000 (07:54 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 18 Feb 2026 12:26:21 +0000 (13:26 +0100)
When the compression is performed, a trash chunk is used. So be sure to
never compression more data than the trash size. Otherwise the commression
could fail. Today, this cannot happen. But with the large buffers support on
channels, it could be an issue.

Note that this part should be reviewed to evaluate if we should use a larger
chunk too to perform the compression, maybe via an option.

src/flt_http_comp.c

index 002d074eb2bcdff131cac91f261234752acb30e4..79dbcb84a70d401fe6ec58de769b027ec78632e1 100644 (file)
@@ -302,6 +302,10 @@ comp_http_payload(struct stream *s, struct filter *filter, struct http_msg *msg,
                                        last = 0;
                                        v.len = len;
                                }
+                               if (v.len > b_size(&trash)) {
+                                       last = 0;
+                                       v.len = b_size(&trash);
+                               }
 
                                ret = htx_compression_buffer_add_data(st, v.ptr, v.len, &trash, dir);
                                if (ret < 0 || htx_compression_buffer_end(st, &trash, last, dir) < 0)