]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
cache: Tolerate object deserialization failures
authorPhil Sutter <phil@nwl.cc>
Fri, 16 May 2025 17:36:37 +0000 (19:36 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 13 Aug 2025 17:24:42 +0000 (19:24 +0200)
commit 610089f273c968c983d965f3cac42e4d9784cde8 upstream.

If netlink_delinearize_obj() fails, it will print an error message. Skip
this object and keep going.

Signed-off-by: Phil Sutter <phil@nwl.cc>
Reviewed-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/cache.c

index 90eb901eab64b2d0919848d9ba57ef5a9c30d438..bbba210366920a56da6cf04a8fff738b4681919f 100644 (file)
@@ -740,12 +740,11 @@ static int obj_cache_cb(struct nftnl_obj *nlo, void *arg)
        uint32_t hash;
 
        obj = netlink_delinearize_obj(ctx->nlctx, nlo);
-       if (!obj)
-               return -1;
-
-       obj_name = nftnl_obj_get_str(nlo, NFTNL_OBJ_NAME);
-       hash = djb_hash(obj_name) % NFT_CACHE_HSIZE;
-       cache_add(&obj->cache, &ctx->table->obj_cache, hash);
+       if (obj) {
+               obj_name = nftnl_obj_get_str(nlo, NFTNL_OBJ_NAME);
+               hash = djb_hash(obj_name) % NFT_CACHE_HSIZE;
+               cache_add(&obj->cache, &ctx->table->obj_cache, hash);
+       }
 
        return 0;
 }