]> 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)
committerPhil Sutter <phil@nwl.cc>
Sun, 25 May 2025 07:55:35 +0000 (09:55 +0200)
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 e89acdf55a9b08d65643090d212d803b82a69eb3..3ac819cf68fb7e240f03a5f1b78278df188e63fc 100644 (file)
@@ -871,12 +871,11 @@ static int obj_cache_cb(struct nftnl_obj *nlo, void *arg)
                return 0;
 
        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);
+       }
 
        nftnl_obj_list_del(nlo);
        nftnl_obj_free(nlo);