Skip to contentSkip to conversation

parser_json: reject empty jump/goto chain

PATCH Superseded Pablo Neira Ayuso 1 participant 1 message Mar 31, 2025 netfilter

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 1/1 parser_json: reject empty jump/goto chain

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")

---
This is extra, on top of Florian's fix to address this from the evalution step, not a replacement.

 src/parser_json.c | 3 +++
 1 file changed, 3 insertions(+)
src/parser_json.c +3 -0
index 04d762741e4a..ef7740840710 100644
@@ -1350,6 +1350,9 @@ static struct expr *json_parse_verdict_expr(struct json_ctx *ctx,
 		    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));
 	}
Signature · 1 line
2.30.2