From: Ilia Shipitsin Date: Mon, 23 Dec 2024 21:00:10 +0000 (+0100) Subject: BUG/MINOR: listener: handle a possible strdup() failure X-Git-Tag: v3.2-dev2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=89c62693dafc82650720e249628feb9d172d5b56;p=thirdparty%2Fhaproxy.git BUG/MINOR: listener: 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/listener.c b/src/listener.c index 5f3a98b4a8..5e423eb573 100644 --- a/src/listener.c +++ b/src/listener.c @@ -2369,8 +2369,13 @@ static int bind_parse_name(char **args, int cur_arg, struct proxy *px, struct bi return ERR_ALERT | ERR_FATAL; } - list_for_each_entry(l, &conf->listeners, by_bind) + list_for_each_entry(l, &conf->listeners, by_bind) { l->name = strdup(args[cur_arg + 1]); + if (!l->name) { + memprintf(err, "'%s %s' : out of memory", args[cur_arg], args[cur_arg + 1]); + return ERR_ALERT | ERR_FATAL; + } + } return 0; }