BUG/MINOR: http: Missing calloc return value check in make_arg_list
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.
(cherry picked from commit 17acbab0ac5933205788eb0a134f9e918247efef)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 6d303d66057957dead2b26e8cd865cd30054902d)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
diff --git a/src/arg.c b/src/arg.c
index 982bab5..7c2e48f 100644
--- a/src/arg.c
+++ b/src/arg.c
@@ -149,6 +149,9 @@
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;
@@ -435,4 +438,7 @@
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;
}