]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: pool: handle a possible strdup() failure
authorIlia Shipitsin <chipitsine@gmail.com>
Fri, 27 Dec 2024 20:55:07 +0000 (21:55 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 2 Jan 2025 13:31:07 +0000 (14:31 +0100)
This defect was found by the coccinelle script "unchecked-strdup.cocci".
It can be backported to all supported branches.

src/pool.c

index f4a4af10056ce682b26b0ce489096c88b1af0aa6..d653ac3c9146e55bde10201045d7d7bfad9c5c4e 100644 (file)
@@ -1373,6 +1373,8 @@ static int cli_parse_show_pools(char **args, char *payload, struct appctx *appct
                }
                else if (strcmp(args[arg], "match") == 0 && *args[arg+1]) {
                        ctx->prefix = strdup(args[arg+1]); // only pools starting with this
+                       if (!ctx->prefix)
+                               return cli_err(appctx, "Out of memory.\n");
                        arg++;
                }
                else if (isdigit((unsigned char)*args[arg])) {