diff mbox series

[nft] parser_json: Fix crash in error reporting

Message ID 20180829142509.10350-1-phil@nwl.cc
State Accepted
Delegated to: Pablo Neira
Headers show
Series [nft] parser_json: Fix crash in error reporting | expand

Commit Message

Phil Sutter Aug. 29, 2018, 2:25 p.m. UTC
When trying to add a chain to a non-existing table, error reporting
tries to dereference indesc pointer of the table's location. Hence make
sure the latter is initialized correctly.

Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 src/parser_json.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Pablo Neira Ayuso Aug. 30, 2018, 10:27 a.m. UTC | #1
On Wed, Aug 29, 2018 at 04:25:09PM +0200, Phil Sutter wrote:
> When trying to add a chain to a non-existing table, error reporting
> tries to dereference indesc pointer of the table's location. Hence make
> sure the latter is initialized correctly.

Applied, thanks Phil.
diff mbox series

Patch

diff --git a/src/parser_json.c b/src/parser_json.c
index ce85b798e908e..c97fea44b95d8 100644
--- a/src/parser_json.c
+++ b/src/parser_json.c
@@ -2154,7 +2154,9 @@  static struct stmt *json_parse_stmt(struct json_ctx *ctx, json_t *root)
 static struct cmd *json_parse_cmd_add_table(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,
+	};
 	const char *family = "";
 
 	if (json_unpack_err(ctx, root, "{s:s}",
@@ -2192,7 +2194,9 @@  static int parse_policy(const char *policy)
 static struct cmd *json_parse_cmd_add_chain(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,
+	};
 	const char *family = "", *policy = "", *type, *hookstr;
 	int prio;
 	struct chain *chain;