summaryrefslogtreecommitdiffstats
path: root/src/netlink.c
diff options
context:
space:
mode:
authorFlorian Westphal <fw@strlen.de>2021-03-31 01:26:19 +0200
committerFlorian Westphal <fw@strlen.de>2021-04-01 14:22:13 +0200
commit3d6cf7f355f80d8ca6c6378c4f399675360c0f8e (patch)
tree95e847b54acd15ab08a88557cbfdf93eefda9c14 /src/netlink.c
parent08a032bc8352f86a4d496331ac7eb1b09620cc78 (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/netlink.c')
-rw-r--r--src/netlink.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/netlink.c b/src/netlink.c
index 103fdbd1..97ae88c7 100644
--- a/src/netlink.c
+++ b/src/netlink.c
@@ -120,6 +120,9 @@ static struct nftnl_set_elem *alloc_nftnl_setelem(const struct expr *set,
} else {
elem = expr;
}
+ if (elem->etype != EXPR_SET_ELEM)
+ BUG("Unexpected expression type: got %d\n", elem->etype);
+
key = elem->key;
netlink_gen_data(key, &nld);