From bbd1cedefcdb39b4ea2e82c0ba2ca219a2fb4f5f Mon Sep 17 00:00:00 2001 From: Ilia Shipitsin Date: Fri, 27 Dec 2024 21:55:38 +0100 Subject: [PATCH] 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. --- src/cfgparse-tcp.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cfgparse-tcp.c b/src/cfgparse-tcp.c index 2f68daf1c..2c214f3d8 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