mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-02-17 02:56:51 +00:00
BUG/MINOR: sample: always check converters' arguments
In 1.5-dev20, sample-fetch arguments parsing was addresse by commit
689a1df0a1
("BUG/MEDIUM: sample: simplify and fix the argument parsing").
The issue was that argument checks were not run for sample-fetches if
parenthesis were not present. Surprisingly, the fix was mde only for
sample-fetches and not for converters which suffer from the exact same
problem. There are even a few comments in the code mentioning that some
argument validation functions are not called when arguments are missing.
This fix applies the exact same method as the one above. The impact of
this bug is limited because over the years the code has learned to work
around this issue instead of fixing it.
This may be backported to all maintained versions.
This commit is contained in:
parent
5060326798
commit
46dfd78cbf
24
src/sample.c
24
src/sample.c
@ -921,6 +921,8 @@ struct sample_expr *sample_parse_expr(char **str, int *idx, const char *file, in
|
||||
|
||||
while (1) {
|
||||
struct sample_conv_expr *conv_expr;
|
||||
int err_arg;
|
||||
int argcnt;
|
||||
|
||||
if (*endt == ')') /* skip last closing parenthesis */
|
||||
endt++;
|
||||
@ -963,6 +965,7 @@ struct sample_expr *sample_parse_expr(char **str, int *idx, const char *file, in
|
||||
endt = endw;
|
||||
if (*endt == '(') {
|
||||
/* look for the end of this term */
|
||||
endt = ++endw;
|
||||
while (*endt && *endt != ')')
|
||||
endt++;
|
||||
if (*endt != ')') {
|
||||
@ -990,18 +993,16 @@ struct sample_expr *sample_parse_expr(char **str, int *idx, const char *file, in
|
||||
LIST_ADDQ(&(expr->conv_exprs), &(conv_expr->list));
|
||||
conv_expr->conv = conv;
|
||||
|
||||
if (endt != endw) {
|
||||
int err_arg;
|
||||
|
||||
if (!conv->arg_mask) {
|
||||
memprintf(err_msg, "converter '%s' does not support any args", ckw);
|
||||
al->kw = expr->fetch->kw;
|
||||
al->conv = conv_expr->conv->kw;
|
||||
argcnt = make_arg_list(endw, endt - endw, conv->arg_mask, &conv_expr->arg_p, err_msg, NULL, &err_arg, al);
|
||||
if (argcnt < 0) {
|
||||
memprintf(err_msg, "invalid arg %d in converter '%s' : %s", err_arg+1, ckw, *err_msg);
|
||||
goto out_error;
|
||||
}
|
||||
|
||||
al->kw = expr->fetch->kw;
|
||||
al->conv = conv_expr->conv->kw;
|
||||
if (make_arg_list(endw + 1, endt - endw - 1, conv->arg_mask, &conv_expr->arg_p, err_msg, NULL, &err_arg, al) < 0) {
|
||||
memprintf(err_msg, "invalid arg %d in converter '%s' : %s", err_arg+1, ckw, *err_msg);
|
||||
if (argcnt && !conv->arg_mask) {
|
||||
memprintf(err_msg, "converter '%s' does not support any args", ckw);
|
||||
goto out_error;
|
||||
}
|
||||
|
||||
@ -1013,11 +1014,6 @@ struct sample_expr *sample_parse_expr(char **str, int *idx, const char *file, in
|
||||
goto out_error;
|
||||
}
|
||||
}
|
||||
else if (ARGM(conv->arg_mask)) {
|
||||
memprintf(err_msg, "missing args for converter '%s'", ckw);
|
||||
goto out_error;
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
free(fkw);
|
||||
|
Loading…
Reference in New Issue
Block a user