]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
json: init parser state for every new buffer/file
authorEric Garver <eric@garver.life>
Fri, 19 Feb 2021 15:11:26 +0000 (10:11 -0500)
committerPhil Sutter <phil@nwl.cc>
Fri, 19 Feb 2021 15:42:11 +0000 (16:42 +0100)
Otherwise invalid error states cause subsequent json parsing to fail
when it should not.

Signed-off-by: Eric Garver <eric@garver.life>
Signed-off-by: Phil Sutter <phil@nwl.cc>
src/parser_json.c

index 2d132caf529cd3239b1f361be177be2ef4c55eac..ddbf9d9c027b159d724aa7e08b6848d7871436e6 100644 (file)
@@ -3893,6 +3893,7 @@ int nft_parse_json_buffer(struct nft_ctx *nft, const char *buf,
        };
        int ret;
 
+       parser_init(nft, nft->state, msgs, cmds, nft->top_scope);
        nft->json_root = json_loads(buf, 0, NULL);
        if (!nft->json_root)
                return -EINVAL;
@@ -3921,6 +3922,7 @@ int nft_parse_json_filename(struct nft_ctx *nft, const char *filename,
        json_error_t err;
        int ret;
 
+       parser_init(nft, nft->state, msgs, cmds, nft->top_scope);
        nft->json_root = json_load_file(filename, 0, &err);
        if (!nft->json_root)
                return -EINVAL;