]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: cache/stats: Handle inbuf allocation failure in the I/O handler
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 12 Apr 2024 12:36:47 +0000 (14:36 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 12 Apr 2024 13:00:04 +0000 (15:00 +0200)
When cache and stats applets were changed to use their own buffers, a change
was also performed to no longer access the stream from the I/O
handller. Among other things, the HTTP start-line of the request is now
retrieved to get the method. But, when these changes were brought, the inbuf
buffer allocation failures were not handled.

It is of course not so common. But if this happens, a crash may be
experienced. To fix the issue, we now check for inbuf allocation failures
before accessing it.

No backported needed.

src/cache.c
src/stats.c

index 79de40c5f5b821aad29ffce482ff6390128fb707..caa072ff22ff9faed310eb84e2260522faffb2b7 100644 (file)
@@ -1808,6 +1808,10 @@ static void http_cache_io_handler(struct appctx *appctx)
        if (appctx->st0 == HTX_CACHE_HEADER) {
                struct ist meth;
 
+               if (unlikely(applet_fl_test(appctx, APPCTX_FL_INBLK_ALLOC))) {
+                       goto exit;
+               }
+
                /* Headers must be dump at once. Otherwise it is an error */
                ret = htx_cache_dump_msg(appctx, res_htx, len, HTX_BLK_EOH);
                if (!ret || (htx_get_tail_type(res_htx) != HTX_BLK_EOH) ||
index 76fe2b70d5c64ff6b816573561c7a341ea07e36d..a7163732e8a4640c18f8baa6e09553a39191d252 100644 (file)
@@ -4494,7 +4494,7 @@ static void http_stats_io_handler(struct appctx *appctx)
        /* only proxy stats are available via http */
        ctx->domain = STATS_DOMAIN_PROXY;
 
-       if (applet_fl_test(appctx, APPCTX_FL_OUTBLK_ALLOC|APPCTX_FL_OUTBLK_FULL))
+       if (applet_fl_test(appctx, APPCTX_FL_INBLK_ALLOC|APPCTX_FL_OUTBLK_ALLOC|APPCTX_FL_OUTBLK_FULL))
                goto out;
 
        if (applet_fl_test(appctx, APPCTX_FL_FASTFWD) && se_fl_test(appctx->sedesc, SE_FL_MAY_FASTFWD_PROD))