]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
rule: skip CMD_OBJ_SETELEMS with no elements after set flush master
authorPablo Neira Ayuso <pablo@netfilter.org>
Wed, 19 Nov 2025 23:41:13 +0000 (00:41 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 24 Nov 2025 22:37:14 +0000 (23:37 +0100)
Set declaration + set flush results in a crash because CMD_OBJ_SETELEMS
does not expect no elements. This internal command only shows up if set
contains elements, however, evaluation flushes set content after the set
expansion. Skip this command CMD_OBJ_SETELEMS if set is empty.

Fixes: d3c8051cb767 ("rule: rework CMD_OBJ_SETELEMS logic")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/rule.c

index bb6f62c8ab7357180b2a16ad968a4aa64e6b3743..8f8b77f1e8836e3f3c156be006ac5a0e25780c27 100644 (file)
@@ -1499,6 +1499,9 @@ static int do_add_setelems(struct netlink_ctx *ctx, struct cmd *cmd,
 {
        struct set *set = cmd->set;
 
 {
        struct set *set = cmd->set;
 
+       if (!set->init)
+               return 0;
+
        return __do_add_elements(ctx, cmd, set, set->init, flags);
 }
 
        return __do_add_elements(ctx, cmd, set, set->init, flags);
 }