From a66f608222f2b81100265bc10014c69bc633b140 Mon Sep 17 00:00:00 2001 From: Florian Westphal Date: Thu, 27 Mar 2025 09:07:52 +0100 Subject: [PATCH] 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 --- src/json.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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: -- 2.47.3