]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: http: Missing calloc return value check while parsing redirect rule
authorRemi Tricot-Le Breton <rlebreton@haproxy.com>
Wed, 19 May 2021 09:32:04 +0000 (11:32 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 31 May 2021 08:51:08 +0000 (10:51 +0200)
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.

src/http_rules.c

index 318603698e2c897046787371a04545065ac8ff39..6ad1e9c2d0504b4d3442bfcdd27745b47d2d1f15 100644 (file)
@@ -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);