]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: proxy: Missing calloc return value check in proxy_defproxy_cpy
authorRemi Tricot-Le Breton <rlebreton@haproxy.com>
Wed, 12 May 2021 16:07:27 +0000 (18:07 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 31 May 2021 08:50:59 +0000 (10:50 +0200)
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.

src/proxy.c

index 079280c9c1d0b379ac62f852aace3eaf5c8ee76c..0e96571c022c26c72d4a5fb07a417731bd09aac4 100644 (file)
@@ -1717,6 +1717,10 @@ static int proxy_defproxy_cpy(struct proxy *curproxy, const struct proxy *defpro
        /* default compression options */
        if (defproxy->comp != NULL) {
                curproxy->comp = calloc(1, sizeof(*curproxy->comp));
+               if (!curproxy->comp) {
+                       memprintf(errmsg, "proxy '%s': out of memory for default compression options", curproxy->id);
+                       return 1;
+               }
                curproxy->comp->algos = defproxy->comp->algos;
                curproxy->comp->types = defproxy->comp->types;
        }