From: Olivier Houchard Date: Wed, 2 Dec 2026 14:11:12 +0000 (+0100) Subject: BUG/MEDIUM: flt-decomp: allocate the buffer to emit pending data X-Git-Tag: v3.5.0~9 X-Git-Url: https://git.kaiwu.me/web/ngx_http_auth_basic_module.html?a=commitdiff_plain;h=dacf94cad5344e7ccf9f84e104bc6b0e46597ea0;p=haproxy.git BUG/MEDIUM: flt-decomp: allocate the buffer to emit pending data When the decompressed data do not fit in the buffer, the remaining ones are emitted on a next call. But once the first part was sent, the channel buffer may have been released, and in this case nothing could be emitted and the message was stuck. This happens with requests whose EOM is carried by the last DATA block (content-length in H1, or H2) when this block is decompressed into more than a buffer, e.g. 30kB of text: the client gets a 504. Now the buffer is allocated when the filter still has something to emit. Since the HTX message seen by the caller changes in this case, it is now retrieved again after the call to the filters, in both http_request_forward_body() and http_response_forward_body(). The filter was introduced in 3.5-dev6, so no backport is needed. --- diff --git a/src/flt_decomp.c b/src/flt_decomp.c index 2a781ceb2..5603f6155 100644 --- a/src/flt_decomp.c +++ b/src/flt_decomp.c @@ -244,6 +244,13 @@ static int decomp_stream_blk(struct stream *s, struct filter *f, struct channel goto end; } + /* the buffer may have been released while data are still to be emitted */ + if (!b_size(&chn->buf) && (st->decomp_ctx->drain_len || (st->flags & DECOMP_STATE_EOM_SEEN))) { + if (!channel_alloc_buffer(chn, &s->buffer_wait)) + goto end; + htx = htx_from_buf(&chn->buf); + } + htxret = htx_find_offset(htx, offset); offset = htxret.ret; blk = htxret.blk; diff --git a/src/http_ana.c b/src/http_ana.c index 6ff4fba44..c2f23821d 100644 --- a/src/http_ana.c +++ b/src/http_ana.c @@ -1017,6 +1017,8 @@ int http_request_forward_body(struct stream *s, struct channel *req, int an_bit) ret = flt_http_payload(s, msg, htx->data); if (ret < 0) goto return_bad_req; + /* a filter may have allocated the buffer */ + htx = htxbuf(&req->buf); c_adv(req, ret); } else { @@ -2269,6 +2271,8 @@ int http_response_forward_body(struct stream *s, struct channel *res, int an_bit ret = flt_http_payload(s, msg, htx->data); if (ret < 0) goto return_bad_res; + /* a filter may have allocated the buffer */ + htx = htxbuf(&res->buf); c_adv(res, ret); } else {