]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: cfgparse-tcp: handle a possible strdup() failure
authorIlia Shipitsin <chipitsine@gmail.com>
Fri, 27 Dec 2024 20:55:38 +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/cfgparse-tcp.c

index 2f68daf1c23c7dcffb36519ecdbd9ce5a1257b34..2c214f3d823ea1600438a3d8878d703c6f4f4d18 100644 (file)
@@ -144,6 +144,10 @@ static int bind_parse_interface(char **args, int cur_arg, struct proxy *px, stru
 
        ha_free(&conf->settings.interface);
        conf->settings.interface = strdup(args[cur_arg + 1]);
+       if (!conf->settings.interface) {
+               memprintf(err, "'%s %s' : out of memory", args[cur_arg], args[cur_arg + 1]);
+               return ERR_ALERT | ERR_FATAL;
+       }
        return 0;
 }
 #endif