]> git.ipfire.org Git - thirdparty/nftables.git/commit
netlink: don't crash when set elements are not evaluated as expected
authorFlorian Westphal <fw@strlen.de>
Tue, 30 Mar 2021 23:26:19 +0000 (01:26 +0200)
committerFlorian Westphal <fw@strlen.de>
Thu, 1 Apr 2021 12:22:13 +0000 (14:22 +0200)
commit3d6cf7f355f80d8ca6c6378c4f399675360c0f8e
tree95e847b54acd15ab08a88557cbfdf93eefda9c14
parent08a032bc8352f86a4d496331ac7eb1b09620cc78
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>
src/evaluate.c
src/netlink.c