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.
diff --git a/src/cfgcond.c b/src/cfgcond.c
index df8e4d0..ac83b30 100644
--- a/src/cfgcond.c
+++ b/src/cfgcond.c
@@ -195,6 +195,16 @@
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 @@
/* ret == 0, no other way to parse this */
ret = -1;
memprintf(err, "unparsable conditional expression '%s'", args[0]);
+ fail:
if (errptr)
*errptr = text;
done: