From: Phil Sutter Date: Wed, 11 Jun 2025 12:15:38 +0000 (+0200) Subject: netlink: Do not allocate a bogus flowtable priority expr X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=10b9a85b3278e0933bf47226588fede8c9fcbcc8;p=thirdparty%2Fnftables.git netlink: Do not allocate a bogus flowtable priority expr 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 Reviewed-by: Pablo Neira Ayuso --- diff --git a/src/netlink.c b/src/netlink.c index 0e0d32b8..be1fefc0 100644 --- a/src/netlink.c +++ b/src/netlink.c @@ -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 =