]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: arg: don't reject missing optional args
authorWilly Tarreau <w@1wt.eu>
Fri, 28 Feb 2020 15:41:29 +0000 (16:41 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 28 Feb 2020 15:41:29 +0000 (16:41 +0100)
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

index 90742265cc477ac06cb6d01d24241b2ca9246420..adaff1293bcaf467fcb75b756ec5e90613aa6602 100644 (file)
--- 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;