Skip to contentSkip to conversation

parser_json: fix crash on insert rule to bad references

PATCH In review Eric Garver 2 participants 2 messages Sep 10, 2019 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 parser_json: fix crash on insert rule to bad references

Pass the location via the handle so the error leg in erec_print_list() can reference it. Applies to invalid references to tables, chains, and indexes.

Fixes 586ad210368b ("libnftables: Implement JSON parser")
---
 src/parser_json.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
src/parser_json.c +5 -1
index 8ca07d717b13..183d9c972181 100644
@@ -3258,7 +3258,11 @@ static struct cmd *json_parse_cmd_add(struct json_ctx *ctx,
 static struct cmd *json_parse_cmd_replace(struct json_ctx *ctx,
 					  json_t *root, enum cmd_ops op)
 {
-	struct handle h = { 0 };
+	struct handle h = {
+		.table.location = *int_loc,
+		.chain.location = *int_loc,
+		.index.location = *int_loc,
+	};
 	json_t *tmp, *value;
 	const char *family;
 	struct rule *rule;
Signature · 1 line
2.20.1
reviewer
#1 lore raw
Quoted 6 lines · Eric Garver

Pass the location via the handle so the error leg in erec_print_list() can reference it. Applies to invalid references to tables, chains, and indexes.

Fixes 586ad210368b ("libnftables: Implement JSON parser")

Also applied, thanks!