]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
DEBUG: cache: Update underlying buffer when loading HTX message in cache applet
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 7 Mar 2022 15:44:30 +0000 (16:44 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 8 Mar 2022 17:29:20 +0000 (18:29 +0100)
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.

src/cache.c

index d50dc9f1ca390b68488181fcbc2f9a4ec1f56036..60f9a0ed7431a2d48f255b2d09793de34582f472 100644 (file)
@@ -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))