]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
json: return error if table does not exist
authorFlorian Westphal <fw@strlen.de>
Thu, 27 Mar 2025 08:07:52 +0000 (09:07 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 13 Aug 2025 16:15:40 +0000 (18:15 +0200)
commit 2200a105d4befc15b0cfa6cc24282e493888dc82 upstream.

Identical bug and thus same fix as
853d3a2d3cbd ("rule: return error if table does not exist"),
but this time for json.

Signed-off-by: Florian Westphal <fw@strlen.de>
src/json.c

index 71fa62b3a6cf7cfcd07845cd473e8b37315c8538..9c39e418fc53f6dc48df3993020062d2da5b35b9 100644 (file)
@@ -1960,10 +1960,15 @@ int do_command_list_json(struct netlink_ctx *ctx, struct cmd *cmd)
        struct table *table = NULL;
        json_t *root;
 
-       if (cmd->handle.table.name)
+       if (cmd->handle.table.name) {
                table = table_cache_find(&ctx->nft->cache.table_cache,
                                         cmd->handle.table.name,
                                         cmd->handle.family);
+               if (!table) {
+                       errno = ENOENT;
+                       return -1;
+               }
+       }
 
        switch (cmd->obj) {
        case CMD_OBJ_TABLE: