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 Jrme for reporting this issue. No backport is needed,
this is 2.2-dev2+ only.
This commit is contained in:
Willy Tarreau 2020-02-28 16:41:29 +01:00
parent 493d9dc6ba
commit 77e463f729

View File

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