Skip to contentSkip to conversation

parser_json: fix crash on add rule to bad references

PATCH Applied Eric Garver 3 participants 3 messages May 1, 2019 – May 3, 2019 netfilter

lore
Share & tools
lore
#0 lore raw

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

Pass the location via the handle so the error leg in rule_translate_index() 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 10ce259f0241..3fbb4457ddac 100644
@@ -2429,7 +2429,11 @@ static struct cmd *json_parse_cmd_add_chain(struct json_ctx *ctx, json_t *root,
 static struct cmd *json_parse_cmd_add_rule(struct json_ctx *ctx, json_t *root,
 					   enum cmd_ops op, enum cmd_obj obj)
 {
-	struct handle h = { 0 };
+	struct handle h = {
+		.table.location = *int_loc,
+		.chain.location = *int_loc,
+		.index.location = *int_loc,
+	};
 	const char *family = "", *comment = NULL;
 	struct rule *rule;
 	size_t index;
Signature · 1 line
2.20.1
maintainer Applied
#2 lore raw
In reply to Eric Garver
Quoted 3 lines · Eric Garver

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

Applied, thanks.