]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
parser_json: fix crash on add rule to bad references
authorEric Garver <eric@garver.life>
Wed, 1 May 2019 16:34:45 +0000 (12:34 -0400)
committerPablo Neira Ayuso <pablo@netfilter.org>
Fri, 3 May 2019 16:14:38 +0000 (18:14 +0200)
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>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/parser_json.c

index c57c4b8afc02e89175c65c6d2b6af5086fa44816..3dc3a5c5f93ce284bbec98cc13e90265e0932877 100644 (file)
@@ -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;