Blame SOURCES/0041-json-init-parser-state-for-every-new-buffer-file.patch

742238
From 2b4da3af37ac10d96650da1b8642f82a3aa92e30 Mon Sep 17 00:00:00 2001
742238
From: Phil Sutter <psutter@redhat.com>
742238
Date: Sat, 20 Feb 2021 09:52:59 +0100
742238
Subject: [PATCH] json: init parser state for every new buffer/file
742238
742238
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1930873
742238
Upstream Status: nftables commit 267338ec39234
742238
742238
commit 267338ec392346ef55ed51509e5f8e8354d6c19a
742238
Author: Eric Garver <eric@garver.life>
742238
Date:   Fri Feb 19 10:11:26 2021 -0500
742238
742238
    json: init parser state for every new buffer/file
742238
742238
    Otherwise invalid error states cause subsequent json parsing to fail
742238
    when it should not.
742238
742238
    Signed-off-by: Eric Garver <eric@garver.life>
742238
    Signed-off-by: Phil Sutter <phil@nwl.cc>
742238
---
742238
 src/parser_json.c | 2 ++
742238
 1 file changed, 2 insertions(+)
742238
742238
diff --git a/src/parser_json.c b/src/parser_json.c
742238
index 986f128..662bb4b 100644
742238
--- a/src/parser_json.c
742238
+++ b/src/parser_json.c
742238
@@ -3777,6 +3777,7 @@ int nft_parse_json_buffer(struct nft_ctx *nft, const char *buf,
742238
 	};
742238
 	int ret;
742238
 
742238
+	parser_init(nft, nft->state, msgs, cmds, nft->top_scope);
742238
 	nft->json_root = json_loads(buf, 0, NULL);
742238
 	if (!nft->json_root)
742238
 		return -EINVAL;
742238
@@ -3805,6 +3806,7 @@ int nft_parse_json_filename(struct nft_ctx *nft, const char *filename,
742238
 	json_error_t err;
742238
 	int ret;
742238
 
742238
+	parser_init(nft, nft->state, msgs, cmds, nft->top_scope);
742238
 	nft->json_root = json_load_file(filename, 0, &err;;
742238
 	if (!nft->json_root)
742238
 		return -EINVAL;
742238
-- 
742238
1.8.3.1
742238