From: Florian Westphal Date: Thu, 27 Mar 2025 08:07:52 +0000 (+0100) Subject: json: return error if table does not exist X-Git-Tag: v1.0.6.1~73 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a66f608222f2b81100265bc10014c69bc633b140;p=thirdparty%2Fnftables.git json: return error if table does not exist 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 --- diff --git a/src/json.c b/src/json.c index 71fa62b3..9c39e418 100644 --- a/src/json.c +++ b/src/json.c @@ -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: