From fa7ff6fc9decfb1679198bb4e4cfe4950ea0dce4 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Mon, 7 Mar 2022 16:44:30 +0100 Subject: [PATCH] DEBUG: cache: Update underlying buffer when loading HTX message in cache applet In the I/O handler of the cache applet, we must update the underlying buffer when the HTX message is loaded, using htx_from_buf() function instead of htxbuf(). It is important because the applet will update the message by adding new HTX blocks. This way, the state of the underlying buffer remains consistant with the state of the HTX message. It is especially important if HAProxy is compiled with "DEBUG_STRICT=2" mode. Without this patch, channel_add_input() call crashed if the channel was empty at the begining of the I/O handler. Note that it is more a build/debug issue than a bug. But this patch may prevent future bugs. For now it is safe because htx_to_buf() function is systematically called, updating accordingly the underlying buffer. This patch may be backported as far as 2.0. (cherry picked from commit 8b1eed16d0f63227a0026f4253c12c1cf68f2f0c) Signed-off-by: Christopher Faulet --- src/cache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cache.c b/src/cache.c index 87be4a2..1b0bb26 100644 --- a/src/cache.c +++ b/src/cache.c @@ -1437,7 +1437,7 @@ static void http_cache_io_handler(struct appctx *appctx) unsigned int len; size_t ret, total = 0; - res_htx = htxbuf(&res->buf); + res_htx = htx_from_buf(&res->buf); total = res_htx->data; if (unlikely(si->state == SI_ST_DIS || si->state == SI_ST_CLO)) -- 1.7.10.4