diff options
| author | Pablo Neira Ayuso <pablo@netfilter.org> | 2025-06-15 11:33:49 +0200 |
|---|---|---|
| committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2025-08-13 20:44:50 +0200 |
| commit | 6c67aef5a0b3efb8e64b89f9f97a52cb9657849e (patch) | |
| tree | 818b6da7452780871e40d895c6996a4f45d46edd | |
| parent | 018e5bd610ef9d287de2a36143cce659250341d7 (diff) | |
cache: assert name is non-nul when looking up
commit f15bc7d368b7c1d897fd830f91e7db6929175b27 upstream.
{table,chain,set,obj,flowtable}_cache_find() should not be called when
handles are used
Fixes: 5ec5c706d993 ("cache: add hashtable cache for table")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
| -rw-r--r-- | src/cache.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/cache.c b/src/cache.c index bbba2103..2e96a489 100644 --- a/src/cache.c +++ b/src/cache.c @@ -444,8 +444,7 @@ struct table *table_cache_find(const struct cache *cache, struct table *table; uint32_t hash; - if (!name) - return NULL; + assert(name); hash = djb_hash(name) % NFT_CACHE_HSIZE; list_for_each_entry(table, &cache->ht[hash], cache.hlist) { @@ -565,6 +564,8 @@ struct chain *chain_cache_find(const struct table *table, const char *name) struct chain *chain; uint32_t hash; + assert(name); + hash = djb_hash(name) % NFT_CACHE_HSIZE; list_for_each_entry(chain, &table->chain_cache.ht[hash], cache.hlist) { if (!strcmp(chain->handle.chain.name, name)) @@ -718,6 +719,8 @@ struct set *set_cache_find(const struct table *table, const char *name) struct set *set; uint32_t hash; + assert(name); + hash = djb_hash(name) % NFT_CACHE_HSIZE; list_for_each_entry(set, &table->set_cache.ht[hash], cache.hlist) { if (!strcmp(set->handle.set.name, name)) @@ -803,6 +806,8 @@ struct obj *obj_cache_find(const struct table *table, const char *name, struct obj *obj; uint32_t hash; + assert(name); + hash = djb_hash(name) % NFT_CACHE_HSIZE; list_for_each_entry(obj, &table->obj_cache.ht[hash], cache.hlist) { if (!strcmp(obj->handle.obj.name, name) && @@ -907,6 +912,8 @@ struct flowtable *ft_cache_find(const struct table *table, const char *name) struct flowtable *ft; uint32_t hash; + assert(name); + hash = djb_hash(name) % NFT_CACHE_HSIZE; list_for_each_entry(ft, &table->ft_cache.ht[hash], cache.hlist) { if (!strcmp(ft->handle.flowtable.name, name)) |
