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.1.2~28 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2200a105d4befc15b0cfa6cc24282e493888dc82;p=thirdparty%2Fnftables.git json: return error if table does not exist 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 96413d70..831bc90f 100644 --- a/src/json.c +++ b/src/json.c @@ -1973,10 +1973,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: diff --git a/tests/shell/testcases/bogons/nft-j-f/list_a_destroyed_table_crash b/tests/shell/testcases/bogons/nft-j-f/list_a_destroyed_table_crash new file mode 100644 index 00000000..f06145c7 --- /dev/null +++ b/tests/shell/testcases/bogons/nft-j-f/list_a_destroyed_table_crash @@ -0,0 +1,3 @@ +table t +list table t +destroy table t