]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
src: netlink: fix crash when ops doesn't support udata
authorFlorian Westphal <fw@strlen.de>
Thu, 8 May 2025 14:29:04 +0000 (16:29 +0200)
committerFlorian Westphal <fw@strlen.de>
Sun, 11 May 2025 19:29:34 +0000 (21:29 +0200)
Whenever a new version adds udata support to an expression, then old
versions of nft will crash when trying to list such a ruleset generated
by a more recent version of nftables.

Fix this by falling back to 'type' format.

Fixes: 6e48df5329ea ('src: add "typeof" build/parse/print support')
Signed-off-by: Florian Westphal <fw@strlen.de>
Reviewed-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/netlink.c

index 86ca32144f029d8f79c964eef2ebe225da18e0b4..d88912457c59122dd2466496bcce3940ddfe4dc2 100644 (file)
@@ -937,7 +937,7 @@ static struct expr *set_make_key(const struct nftnl_udata *attr)
 
        etype = nftnl_udata_get_u32(ud[NFTNL_UDATA_SET_TYPEOF_EXPR]);
        ops = expr_ops_by_type_u32(etype);
-       if (!ops)
+       if (!ops || !ops->parse_udata)
                return NULL;
 
        expr = ops->parse_udata(ud[NFTNL_UDATA_SET_TYPEOF_DATA]);