diff mbox series

[nft] parser_json: fix crash on add rule to bad references

Message ID 20190501163445.29604-1-eric@garver.life
State Accepted
Delegated to: Pablo Neira
Headers show
Series [nft] parser_json: fix crash on add rule to bad references | expand

Commit Message

Eric Garver May 1, 2019, 4:34 p.m. UTC
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")
Signed-off-by: Eric Garver <eric@garver.life>
---
 src/parser_json.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Phil Sutter May 3, 2019, 3:43 p.m. UTC | #1
On Wed, May 01, 2019 at 12:34:45PM -0400, Eric Garver wrote:
> 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")
> Signed-off-by: Eric Garver <eric@garver.life>

Acked-by: Phil Sutter <phil@nwl.cc>
Pablo Neira Ayuso May 3, 2019, 4:15 p.m. UTC | #2
On Wed, May 01, 2019 at 12:34:45PM -0400, Eric Garver wrote:
> 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.
diff mbox series

Patch

diff --git a/src/parser_json.c b/src/parser_json.c
index 10ce259f0241..3fbb4457ddac 100644
--- a/src/parser_json.c
+++ b/src/parser_json.c
@@ -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;