From: Willy Tarreau Date: Fri, 28 Feb 2020 15:41:29 +0000 (+0100) Subject: BUG/MINOR: arg: don't reject missing optional args X-Git-Tag: v2.2-dev4~101 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=77e463f729de676ec3343ed3318a2cfa5d3a6a8b;p=thirdparty%2Fhaproxy.git BUG/MINOR: arg: don't reject missing optional args Commit 80b53ffb1c ("MEDIUM: arg: make make_arg_list() stop after its own arguments") changed the way we detect the empty list because we cannot stop by looking up the closing parenthesis anymore, thus for the first missing arg we have to enter the parsing loop again. And there, finding an empty arg means we go to the empty_err label, where it was not initially planned to handle this condition. This results in %[date()] to fail while %[date] works. Let's simply check if we've reached the minimally supported args there (it used to be done during the function entry). Thanks to Jérôme for reporting this issue. No backport is needed, this is 2.2-dev2+ only. --- diff --git a/src/arg.c b/src/arg.c index 90742265cc..adaff1293b 100644 --- a/src/arg.c +++ b/src/arg.c @@ -395,6 +395,9 @@ int make_arg_list(const char *in, int len, uint64_t mask, struct arg **argp, return -1; empty_err: + if (pos >= min_arg) + goto end_parse; + memprintf(err_msg, "expected type '%s' at position %d, but got nothing", arg_type_names[(mask >> (pos * ARGT_BITS)) & ARGT_MASK], pos + 1); goto err;