]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
evaluate: check if set exists before listing it
authorPablo Neira Ayuso <pablo@netfilter.org>
Fri, 25 Sep 2015 10:53:40 +0000 (12:53 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 12 Oct 2015 18:34:21 +0000 (20:34 +0200)
After this patch, we obtain:

 # nft list set ip6 test pepe
 <cmdline>:1:1-22: Error: Could not process rule: Set 'foo' does not exist
 list set ip6 test foo
 ^^^^^^^^^^^^^^^^^^^^^

So we get things aligned with table and chain listing commands.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Acked-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
src/evaluate.c

index 976258641cefb44f7f5c21fb19f34fb112acf318..4f9299e14a81732da7b57bf5a5f70c98b6c853eb 100644 (file)
@@ -2091,10 +2091,20 @@ static int cmd_evaluate_list(struct eval_ctx *ctx, struct cmd *cmd)
        case CMD_OBJ_TABLE:
                if (cmd->handle.table == NULL)
                        return 0;
+
+               table = table_lookup(&cmd->handle);
+               if (table == NULL)
+                       return cmd_error(ctx, "Could not process rule: Table '%s' does not exist",
+                                        cmd->handle.table);
+               return 0;
        case CMD_OBJ_SET:
-               if (table_lookup(&cmd->handle) == NULL)
+               table = table_lookup(&cmd->handle);
+               if (table == NULL)
                        return cmd_error(ctx, "Could not process rule: Table '%s' does not exist",
                                         cmd->handle.table);
+               if (set_lookup(table, cmd->handle.set) == NULL)
+                       return cmd_error(ctx, "Could not process rule: Set '%s' does not exist",
+                                        cmd->handle.set);
                return 0;
        case CMD_OBJ_CHAIN:
                table = table_lookup(&cmd->handle);