From: Remi Tricot-Le Breton Date: Wed, 19 May 2021 09:32:04 +0000 (+0200) Subject: BUG/MINOR: http: Missing calloc return value check while parsing redirect rule X-Git-Tag: v2.5-dev1~217 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b6864a5b6fa1ea6eb224710d00c897105b9e2a46;p=thirdparty%2Fhaproxy.git BUG/MINOR: http: Missing calloc return value check while parsing redirect rule A memory allocation failure happening in http_parse_redirect_rule when trying to allocate a redirect_rule structure would have resulted in a crash. This function is only called during configuration parsing. It was raised in GitHub issue #1233. It could be backported to all stable branches. --- diff --git a/src/http_rules.c b/src/http_rules.c index 318603698e..6ad1e9c2d0 100644 --- a/src/http_rules.c +++ b/src/http_rules.c @@ -408,6 +408,10 @@ struct redirect_rule *http_parse_redirect_rule(const char *file, int linenum, st } rule = calloc(1, sizeof(*rule)); + if (!rule) { + memprintf(errmsg, "parsing [%s:%d]: out of memory.", file, linenum); + return NULL; + } rule->cond = cond; LIST_INIT(&rule->rdr_fmt);