From: Ilia Shipitsin Date: Fri, 27 Dec 2024 20:55:38 +0000 (+0100) Subject: BUG/MINOR: cfgparse-tcp: handle a possible strdup() failure X-Git-Tag: v3.2-dev3~16 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bbd1cedefcdb39b4ea2e82c0ba2ca219a2fb4f5f;p=thirdparty%2Fhaproxy.git BUG/MINOR: cfgparse-tcp: handle a possible strdup() failure This defect was found by the coccinelle script "unchecked-strdup.cocci". It can be backported to all supported branches. --- diff --git a/src/cfgparse-tcp.c b/src/cfgparse-tcp.c index 2f68daf1c2..2c214f3d82 100644 --- a/src/cfgparse-tcp.c +++ b/src/cfgparse-tcp.c @@ -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