47 lines
1.4 KiB
Diff
47 lines
1.4 KiB
Diff
|
From 2b4da3af37ac10d96650da1b8642f82a3aa92e30 Mon Sep 17 00:00:00 2001
|
||
|
From: Phil Sutter <psutter@redhat.com>
|
||
|
Date: Sat, 20 Feb 2021 09:52:59 +0100
|
||
|
Subject: [PATCH] json: init parser state for every new buffer/file
|
||
|
|
||
|
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1930873
|
||
|
Upstream Status: nftables commit 267338ec39234
|
||
|
|
||
|
commit 267338ec392346ef55ed51509e5f8e8354d6c19a
|
||
|
Author: Eric Garver <eric@garver.life>
|
||
|
Date: Fri Feb 19 10:11:26 2021 -0500
|
||
|
|
||
|
json: init parser state for every new buffer/file
|
||
|
|
||
|
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 | 2 ++
|
||
|
1 file changed, 2 insertions(+)
|
||
|
|
||
|
diff --git a/src/parser_json.c b/src/parser_json.c
|
||
|
index 986f128..662bb4b 100644
|
||
|
--- a/src/parser_json.c
|
||
|
+++ b/src/parser_json.c
|
||
|
@@ -3777,6 +3777,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;
|
||
|
@@ -3805,6 +3806,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;
|
||
|
--
|
||
|
1.8.3.1
|
||
|
|