]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
netlink: Do not allocate a bogus flowtable priority expr
authorPhil Sutter <phil@nwl.cc>
Wed, 11 Jun 2025 12:15:38 +0000 (14:15 +0200)
committerPhil Sutter <phil@nwl.cc>
Thu, 12 Jun 2025 20:55:42 +0000 (22:55 +0200)
Code accidentally treats missing NFTNL_FLOWTABLE_PRIO attribute as zero
prio value which may not be correct.

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 0e0d32b846d6a85b51fed5cd3cd55e1aac4fc89c..be1fefc068bfde49c6586a0366af4aa2de01a9a8 100644 (file)
@@ -1862,14 +1862,16 @@ netlink_delinearize_flowtable(struct netlink_ctx *ctx,
                      sizeof(char *), qsort_device_cmp);
        }
 
-       priority = nftnl_flowtable_get_u32(nlo, NFTNL_FLOWTABLE_PRIO);
-       flowtable->priority.expr =
+       if (nftnl_flowtable_is_set(nlo, NFTNL_FLOWTABLE_PRIO)) {
+               priority = nftnl_flowtable_get_u32(nlo, NFTNL_FLOWTABLE_PRIO);
+               flowtable->priority.expr =
                                constant_expr_alloc(&netlink_location,
                                                    &integer_type,
                                                    BYTEORDER_HOST_ENDIAN,
                                                    sizeof(int) *
                                                    BITS_PER_BYTE,
                                                    &priority);
+       }
        flowtable->hook.num =
                nftnl_flowtable_get_u32(nlo, NFTNL_FLOWTABLE_HOOKNUM);
        flowtable->flags =