mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-16 08:24:42 +00:00
MEDIUM: cfgcond: report invalid trailing chars after expressions
Random characters placed after a configuration predicate currently do not report an error. This is a problem because extra parenthesis, commas or even other random left-over chars may accidently appear there. Let's now report an error when this happens. This is marked MEDIUM because it may break otherwise working configs which are faulty.
This commit is contained in:
parent
f869095df9
commit
379ceeaaeb
@ -195,6 +195,16 @@ int cfg_eval_condition(char **args, char **err, const char **errptr)
|
||||
if (ret != 0) {
|
||||
if (ret == -1) // parse error, error already reported
|
||||
goto done;
|
||||
while (*text == ' ' || *text == '\t')
|
||||
text++;
|
||||
|
||||
if (*text) {
|
||||
ret = -1;
|
||||
memprintf(err, "unexpected character '%c' at the end of conditional expression '%s'",
|
||||
*text, args[0]);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
ret = cfg_eval_cond_term(&term, err);
|
||||
goto done;
|
||||
}
|
||||
@ -202,6 +212,7 @@ int cfg_eval_condition(char **args, char **err, const char **errptr)
|
||||
/* ret == 0, no other way to parse this */
|
||||
ret = -1;
|
||||
memprintf(err, "unparsable conditional expression '%s'", args[0]);
|
||||
fail:
|
||||
if (errptr)
|
||||
*errptr = text;
|
||||
done:
|
||||
|
Loading…
Reference in New Issue
Block a user