MEDIUM: compression: Be sure to never compress more than a chunk at once

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.
This commit is contained in:
Christopher Faulet
2026-02-03 07:54:11 +01:00
parent 53b7150357
commit f82ace414b

View 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)