diff options
author | Florian Westphal <fw@strlen.de> | 2021-03-31 01:26:19 +0200 |
---|---|---|
committer | Florian Westphal <fw@strlen.de> | 2021-04-01 14:22:13 +0200 |
commit | 3d6cf7f355f80d8ca6c6378c4f399675360c0f8e (patch) | |
tree | 95e847b54acd15ab08a88557cbfdf93eefda9c14 /src/evaluate.c | |
parent | 08a032bc8352f86a4d496331ac7eb1b09620cc78 (diff) |
netlink: don't crash when set elements are not evaluated as expected
define foo = 2001:db8:123::/48
table inet filter {
set foo {
typeof ip6 saddr
elements = $foo
}
}
gives crash. This now exits with:
stdin:1:14-30: Error: Unexpected initial set type prefix
define foo = 2001:db8:123::/48
^^^^^^^^^^^^^^^^^
For literals, bison parser protects us, as it enforces
'elements = { 2001:... '.
For 'elements = $foo' we can't detect it at parsing stage as the '$foo'
symbol might as well evaluate to "{ 2001, ...}" (i.e. we can't do a
set element allocation).
So at least detect this from set instantiaton.
Signed-off-by: Florian Westphal <fw@strlen.de>
Diffstat (limited to 'src/evaluate.c')
-rw-r--r-- | src/evaluate.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/evaluate.c b/src/evaluate.c index cebf7cb8..8105d8d5 100644 --- a/src/evaluate.c +++ b/src/evaluate.c @@ -3787,6 +3787,9 @@ static int set_evaluate(struct eval_ctx *ctx, struct set *set) set->key->byteorder, set->key->len, 0); if (expr_evaluate(ctx, &set->init) < 0) return -1; + if (set->init->etype != EXPR_SET) + return expr_error(ctx->msgs, set->init, "Set %s: Unexpected initial type %s, missing { }?", + set->handle.set.name, expr_name(set->init)); } ctx->set = NULL; |