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.
This commit is contained in:
Remi Tricot-Le Breton 2021-05-19 12:00:54 +02:00 committed by Christopher Faulet
parent b6864a5b6f
commit 17acbab0ac

View File

@ -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;
}