From 77e463f729de676ec3343ed3318a2cfa5d3a6a8b Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 28 Feb 2020 16:41:29 +0100 Subject: [PATCH] BUG/MINOR: arg: don't reject missing optional args MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- src/arg.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/arg.c b/src/arg.c index 90742265c..adaff1293 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;