From 1c3a202760d998833edc6768f457628ee6d8beea Mon Sep 17 00:00:00 2001 From: Remi Tricot-Le Breton Date: Wed, 12 May 2021 18:07:27 +0200 Subject: [PATCH] BUG/MINOR: proxy: Missing calloc return value check in proxy_defproxy_cpy A memory allocation failure happening in proxy_defproxy_cpy while copying the default compression options would have resulted in a crash. This function is called for every new proxy found while parsing the configuration. It was raised in GitHub issue #1233. It could be backported to all stable branches. (cherry picked from commit 18a82ba690a6ff4adbf9702cefa6dc89eb36372d) Signed-off-by: Christopher Faulet (cherry picked from commit 4d8e20f83cc07c08c1d562e6afc5b4d3a54f4058) [Cf: Patch applied on cfgparse-listen.c] Signed-off-by: Christopher Faulet --- src/cfgparse-listen.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/cfgparse-listen.c b/src/cfgparse-listen.c index 01360fe..d5359ff 100644 --- a/src/cfgparse-listen.c +++ b/src/cfgparse-listen.c @@ -449,6 +449,11 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm) /* default compression options */ if (defproxy.comp != NULL) { curproxy->comp = calloc(1, sizeof(*curproxy->comp)); + if (!curproxy->comp) { + ha_alert("parsing [%s:%d] : out of memory for default compression options", file, linenum); + err_code |= ERR_ALERT | ERR_ABORT; + goto out; + } curproxy->comp->algos = defproxy.comp->algos; curproxy->comp->types = defproxy.comp->types; } -- 1.7.10.4