From ef2a2925855a48cecc9632371bec6e105235b73c Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Thu, 12 Mar 2026 21:42:10 +0100 Subject: [PATCH] BUG/MINOR: http-ana: Swap L7 buffer with request buffer by hand When a L7 retry is performed, we should not rely on b_xfer() to swap the L7 buffer with the request buffer. When it is performed the request buffer is not allocated. b_xfer() must not be called with an unallocated destination buffer. The swap remains an optim. For instance, It is not performed on buffers of different size. So the caller is responsible to provide an allocated destination buffer with enough free space to transfer data. However, when a L7 retry is performed, we cannot allocate a request buffer, because we cannot yield. An error was reported, if we wait for a buffer, the error will be handled by process_stream(). But we can swap the buffers by hand. At this stage, we know there is no request buffer, so we can easily swap it with the L7 buffer. Note there is no real bug for now. This patch could be backported to all stable versions. --- src/http_ana.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/http_ana.c b/src/http_ana.c index d878d806d..51d53b3ed 100644 --- a/src/http_ana.c +++ b/src/http_ana.c @@ -1224,11 +1224,14 @@ static __inline int do_l7_retry(struct stream *s, struct stconn *sc) } b_free(&req->buf); + /* Swap the L7 buffer with the channel buffer */ /* We know we stored the co_data as b_data, so get it there */ co_data = b_data(&s->txn->l7_buffer); b_set_data(&s->txn->l7_buffer, b_size(&s->txn->l7_buffer)); - b_xfer(&req->buf, &s->txn->l7_buffer, b_data(&s->txn->l7_buffer)); + + req->buf = s->txn->l7_buffer; + s->txn->l7_buffer = BUF_NULL; co_set_data(req, co_data); DBG_TRACE_DEVEL("perform a L7 retry", STRM_EV_STRM_ANA|STRM_EV_HTTP_ANA, s, s->txn);