]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: http: Missing calloc return value check in make_arg_list
authorRemi Tricot-Le Breton <rlebreton@haproxy.com>
Wed, 19 May 2021 10:00:54 +0000 (12:00 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 31 May 2021 08:51:09 +0000 (10:51 +0200)
A memory allocation failure happening in make_arg_list when trying to
allocate the argument list 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/arg.c

index 5d5766b7458e0b54ac7413c1cb8cfe10ad4d4700..d44f268da8735d88974aa70537972042c481be00 100644 (file)
--- a/src/arg.c
+++ b/src/arg.c
@@ -149,6 +149,9 @@ int make_arg_list(const char *in, int len, uint64_t mask, struct arg **argp,
 
        arg = *argp = calloc(nbarg + 1, sizeof(**argp));
 
+       if (!arg)
+               goto alloc_err;
+
        /* Note: empty arguments after a comma always exist. */
        while (pos < nbarg) {
                unsigned int uint;
@@ -439,4 +442,7 @@ int make_arg_list(const char *in, int len, uint64_t mask, struct arg **argp,
                  in, trash.area, arg_type_names[(mask >> (pos * ARGT_BITS)) & ARGT_MASK], pos + 1);
        goto err;
 
+alloc_err:
+       memprintf(err_msg, "out of memory");
+       goto err;
 }