]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
parser_json: Fix crash in error reporting
authorPhil Sutter <phil@nwl.cc>
Wed, 29 Aug 2018 14:25:09 +0000 (16:25 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 30 Aug 2018 10:19:36 +0000 (12:19 +0200)
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>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/parser_json.c

index 6af9d0755df05ce0703d6cd0fc0a9ace1878cd9e..514bc46bba1b1f48632df118e79cbea0cb3daa3d 100644 (file)
@@ -2212,7 +2212,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}",
@@ -2250,7 +2252,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;