From: Tim Duesterhus Date: Sun, 3 Jan 2021 21:54:43 +0000 (+0100) Subject: BUG/MINOR: cfgparse: Fail if the strdup() for `rule->be.name` for `use_backend` fails X-Git-Tag: v2.4-dev5~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5ce5a1586d8c67affa604dedf0faa2c5a02ecab5;p=thirdparty%2Fhaproxy.git BUG/MINOR: cfgparse: Fail if the strdup() for `rule->be.name` for `use_backend` fails This patch fixes GitHub issue #1024. I could track the `strdup` back to commit 3a1f5fda109fc56ae127d03eaf34ce027c9542e1 which is 1.9-dev8. It's probably not worth the effort to backport it across this refactoring. This patch should be backported to 1.9+. --- diff --git a/src/cfgparse-listen.c b/src/cfgparse-listen.c index 6678e15d1a..588ff9704a 100644 --- a/src/cfgparse-listen.c +++ b/src/cfgparse-listen.c @@ -1510,6 +1510,10 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm) } rule->cond = cond; rule->be.name = strdup(args[1]); + if (!rule->be.name) { + ha_alert("Out of memory error.\n"); + goto out; + } rule->line = linenum; rule->file = strdup(file); if (!rule->file) {