]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
parser_json: fix crash on insert rule to bad references
authorEric Garver <eric@garver.life>
Tue, 10 Sep 2019 13:46:15 +0000 (09:46 -0400)
committerPhil Sutter <phil@nwl.cc>
Tue, 10 Sep 2019 16:10:20 +0000 (18:10 +0200)
Pass the location via the handle so the error leg in
erec_print_list() 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>
Signed-off-by: Phil Sutter <phil@nwl.cc>
src/parser_json.c

index 8ca07d717b13273c6887a5c81c455728e34393c4..183d9c972181e1c8c15221154f2e9a7258bd7093 100644 (file)
@@ -3258,7 +3258,11 @@ static struct cmd *json_parse_cmd_add(struct json_ctx *ctx,
 static struct cmd *json_parse_cmd_replace(struct json_ctx *ctx,
                                          json_t *root, enum cmd_ops op)
 {
-       struct handle h = { 0 };
+       struct handle h = {
+               .table.location = *int_loc,
+               .chain.location = *int_loc,
+               .index.location = *int_loc,
+       };
        json_t *tmp, *value;
        const char *family;
        struct rule *rule;