]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
rule: skip fuzzy lookup if object name is not available
authorPablo Neira Ayuso <pablo@netfilter.org>
Sun, 15 Jun 2025 09:33:42 +0000 (11:33 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 23 Jun 2025 16:41:05 +0000 (18:41 +0200)
Skip fuzzy lookup for suggestions when handles are used.

Note that 4cf97abfee61 ("rule: Avoid segfault with anonymous chains")
already skips it for chain.

Fixes: 285bb67a11ad ("src: introduce simple hints on incorrect set")
Fixes: 9f7817a4e022 ("src: introduce simple hints on incorrect chain")
Fixes: d7476ddd5f7d ("src: introduce simple hints on incorrect table")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/rule.c

index 0945d14a780e9fa9065cd51df191476b57f8f311..c0f7570e233c109e91d7941a6a87ed858c422f21 100644 (file)
@@ -211,6 +211,9 @@ struct set *set_lookup_fuzzy(const char *set_name,
        struct table *table;
        struct set *set;
 
+       if (!set_name)
+               return NULL;
+
        string_misspell_init(&st);
 
        list_for_each_entry(table, &cache->table_cache.list, cache.list) {
@@ -1221,6 +1224,9 @@ struct table *table_lookup_fuzzy(const struct handle *h,
        struct string_misspell_state st;
        struct table *table;
 
+       if (!h->table.name)
+               return NULL;
+
        string_misspell_init(&st);
 
        list_for_each_entry(table, &cache->table_cache.list, cache.list) {
@@ -1703,6 +1709,9 @@ struct obj *obj_lookup_fuzzy(const char *obj_name,
        struct table *table;
        struct obj *obj;
 
+       if (!obj_name)
+               return NULL;
+
        string_misspell_init(&st);
 
        list_for_each_entry(table, &cache->table_cache.list, cache.list) {
@@ -2198,6 +2207,9 @@ struct flowtable *flowtable_lookup_fuzzy(const char *ft_name,
        struct table *table;
        struct flowtable *ft;
 
+       if (!ft_name)
+               return NULL;
+
        string_misspell_init(&st);
 
        list_for_each_entry(table, &cache->table_cache.list, cache.list) {