]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
rule: fix element cache update in __do_add_setelems()
authorPablo Neira Ayuso <pablo@netfilter.org>
Thu, 30 Apr 2020 14:30:15 +0000 (16:30 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 30 Apr 2020 14:40:07 +0000 (16:40 +0200)
The set->init and expr arguments might actually refer to the same list
of elements. Skip set element cache update introduced by dd44081d91ce
("segtree: Fix add and delete of element in same batch") otherwise
list_splice_tail_init() actually operates with the same list as
arguments. Valgrind reports this problem as a memleak since the result
of this operation was an empty set element list.

Fixes: dd44081d91ce ("segtree: Fix add and delete of element in same batch")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/rule.c

index 9e80c0251947274db26587566015a7028e5b1623..23b1cbfc8fb20f6d353c7c360ebcc5d156bf229d 100644 (file)
@@ -1564,7 +1564,7 @@ static int __do_add_setelems(struct netlink_ctx *ctx, struct set *set,
                return -1;
 
        if (!set_is_anonymous(set->flags) &&
-           set->init != NULL &&
+           set->init != NULL && set->init != expr &&
            set->flags & NFT_SET_INTERVAL &&
            set->desc.field_count <= 1) {
                interval_map_decompose(expr);