]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
cache: prevent possible crash rule filter is NULL
authorPablo Neira Ayuso <pablo@netfilter.org>
Tue, 1 Apr 2025 15:36:48 +0000 (17:36 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 1 Apr 2025 19:06:17 +0000 (21:06 +0200)
Similar to 3f0a47f9f00c ("cache: don't crash when filter is NULL").

No real crash observed but it is good to tigthen this.

Fixes: dbff26bfba83 ("cache: consolidate reset command")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/cache.c

index c0d96bd14a800060b86e797f7cfc606efe4faf29..e89acdf55a9b08d65643090d212d803b82a69eb3 100644 (file)
@@ -714,6 +714,7 @@ static int rule_cache_dump(struct netlink_ctx *ctx, const struct handle *h,
        const char *chain = NULL;
        uint64_t rule_handle = 0;
        int family = h->family;
+       bool reset = false;
        bool dump = true;
 
        if (filter) {
@@ -727,11 +728,12 @@ static int rule_cache_dump(struct netlink_ctx *ctx, const struct handle *h,
                }
                if (filter->list.family)
                        family = filter->list.family;
+
+               reset = filter->reset.rule;
        }
 
        rule_cache = mnl_nft_rule_dump(ctx, family,
-                                      table, chain, rule_handle, dump,
-                                      filter->reset.rule);
+                                      table, chain, rule_handle, dump, reset);
        if (rule_cache == NULL) {
                if (errno == EINTR)
                        return -1;