]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: http: Missing calloc return value check while parsing tcp-request rule
authorRemi Tricot-Le Breton <rlebreton@haproxy.com>
Mon, 17 May 2021 08:08:16 +0000 (10:08 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 31 May 2021 08:51:02 +0000 (10:51 +0200)
A memory allocation failure happening in tcp_parse_request_rule while
processing the "capture" keyword and trying to allocate a cap_hdr
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/tcp_rules.c

index edc287b56c8e36eda329e416c27d0af8039a5348..bbd5820b4c0e30351c0206331a394f031f6ed50c 100644 (file)
@@ -826,6 +826,11 @@ static int tcp_parse_request_rule(char **args, int arg, int section_type,
                }
 
                hdr = calloc(1, sizeof(*hdr));
+               if (!hdr) {
+                       memprintf(err, "parsing [%s:%d] : out of memory", file, line);
+                       release_sample_expr(expr);
+                       return -1;
+               }
                hdr->next = curpx->req_cap;
                hdr->name = NULL; /* not a header capture */
                hdr->namelen = 0;