]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
netlink: Fix for potential crash parsing a flowtable
authorPhil Sutter <phil@nwl.cc>
Wed, 11 Jun 2025 11:12:56 +0000 (13:12 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 18 Jun 2025 22:04:39 +0000 (00:04 +0200)
commit d5ef04441eb1de3efc27aa70193fe3d7f0b5c408 upstream.

Kernel's flowtable message might not contain the
NFTA_FLOWTABLE_HOOK_DEVS attribute. In that case, nftnl_flowtable_get()
will return NULL for the respective nftnl attribute.

Fixes: db0697ce7f602 ("src: support for flowtable listing")
Signed-off-by: Phil Sutter <phil@nwl.cc>
Reviewed-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/netlink.c

index 5c639881c01fca39b8a7a37c695755ffe3ac2394..cd5ac38ce146320c41cc29999b67b77c852e9344 100644 (file)
@@ -1830,7 +1830,7 @@ netlink_delinearize_flowtable(struct netlink_ctx *ctx,
        if (nftnl_flowtable_is_set(nlo, NFTNL_FLOWTABLE_FLAGS))
                flowtable->flags = nftnl_flowtable_get_u32(nlo, NFTNL_FLOWTABLE_FLAGS);
        dev_array = nftnl_flowtable_get(nlo, NFTNL_FLOWTABLE_DEVICES);
-       while (dev_array[len])
+       while (dev_array && dev_array[len])
                len++;
 
        if (len)