When parsing a verdict map json where element jumps to chain represented as empty string. internal:0:0-0: Error: Parsing list expression item at index 0 failed. internal:0:0-0: Error: Invalid set elem at index 0. internal:0:0-0: Error: Invalid set elem expression. internal:0:0-0: Error: Parsing command array at index 2 failed. Fixes: 586ad210368b ("libnftables: Implement JSON parser") Signed-off-by: Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx> --- v2: missing check for .need_chain, previous patch breaks. src/parser_json.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/parser_json.c b/src/parser_json.c index 9d5ec2275b30..053dd81a076f 100644 --- a/src/parser_json.c +++ b/src/parser_json.c @@ -1360,9 +1360,13 @@ static struct expr *json_parse_verdict_expr(struct json_ctx *ctx, if (strcmp(type, verdict_tbl[i].name)) continue; - if (verdict_tbl[i].need_chain && - json_unpack_err(ctx, root, "{s:s}", "target", &chain)) - return NULL; + if (verdict_tbl[i].need_chain) { + if (json_unpack_err(ctx, root, "{s:s}", "target", &chain)) + return NULL; + + if (!chain || chain[0] == '\0') + return NULL; + } return verdict_expr_alloc(int_loc, verdict_tbl[i].verdict, json_alloc_chain_expr(chain)); -- 2.30.2