From: Remi Tricot-Le Breton Date: Wed, 19 May 2021 10:00:54 +0000 (+0200) Subject: BUG/MINOR: http: Missing calloc return value check in make_arg_list X-Git-Tag: v2.5-dev1~216 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=17acbab0ac5933205788eb0a134f9e918247efef;p=thirdparty%2Fhaproxy.git 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. --- diff --git a/src/arg.c b/src/arg.c index 5d5766b745..d44f268da8 100644 --- 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; }