]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: proxy: Missing calloc return value check in proxy_parse_declare
authorRemi Tricot-Le Breton <rlebreton@haproxy.com>
Wed, 12 May 2021 16:04:46 +0000 (18:04 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 31 May 2021 08:50:57 +0000 (10:50 +0200)
A memory allocation failure happening during proxy_parse_declare while
processing the "capture" keyword and allocating 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/proxy.c

index ce60df0bd2d87fa49978835e7c17034eddaa6552..079280c9c1d0b379ac62f852aace3eaf5c8ee76c 100644 (file)
@@ -756,6 +756,10 @@ static int proxy_parse_declare(char **args, int section, struct proxy *curpx,
 
                /* register the capture. */
                hdr = calloc(1, sizeof(*hdr));
+               if (!hdr) {
+                       memprintf(err, "proxy '%s': out of memory while registering a capture", curpx->id);
+                       return -1;
+               }
                hdr->name = NULL; /* not a header capture */
                hdr->namelen = 0;
                hdr->len = len;