!73 [sync] PR-70: Fix the apps/json_parse -s (strict) option, default to non-strict

From: @openeuler-sync-bot 
Reviewed-by: @dillon_chen 
Signed-off-by: @dillon_chen
This commit is contained in:
openeuler-ci-bot 2024-12-06 09:43:22 +00:00 committed by Gitee
commit 2a3797896a
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 58 additions and 11 deletions

View File

@ -0,0 +1,37 @@
From 474ee12435e671607c02f764b173258e3a059eda Mon Sep 17 00:00:00 2001
From: Eric Hawicz <erh+git@nimenees.com>
Date: Sun, 3 Nov 2024 19:44:21 -0500
Subject: [PATCH] Fix the apps/json_parse "-s" (strict) option so it actually
does something, and default to non-strict.
---
apps/json_parse.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/apps/json_parse.c b/apps/json_parse.c
index 31221d0..4eb629b 100644
--- a/apps/json_parse.c
+++ b/apps/json_parse.c
@@ -74,11 +74,14 @@ static int parseit(int fd, int (*callback)(struct json_object *))
fprintf(stderr, "unable to allocate json_tokener: %s\n", strerror(errno));
return 1;
}
- json_tokener_set_flags(tok, JSON_TOKENER_STRICT
-#ifdef JSON_TOKENER_ALLOW_TRAILING_CHARS
- | JSON_TOKENER_ALLOW_TRAILING_CHARS
-#endif
- );
+ if (strict_mode)
+ {
+ json_tokener_set_flags(tok, JSON_TOKENER_STRICT
+ #ifdef JSON_TOKENER_ALLOW_TRAILING_CHARS
+ | JSON_TOKENER_ALLOW_TRAILING_CHARS
+ #endif
+ );
+ }
// XXX push this into some kind of json_tokener_parse_fd API?
// json_object_from_fd isn't flexible enough, and mirroring
--
2.33.0

View File

@ -6,7 +6,7 @@
Name: json-c
Version: 0.17
Release: 5
Release: 6
Summary: JSON implementation in C
License: MIT
@ -15,13 +15,14 @@ Source0: %{url}/archive/%{name}-%{version}-%{reldate}.tar.gz
BuildRequires: cmake gcc ninja-build
Patch001: backport-fix-issue-854-Set-error-json_tokener_error_memory-in.patch
Patch002: backport-Handle-yet-another-out-of-memory-condition.patch
Patch003: backport-Issue-857-fix-a-few-places-where-json_tokener-should.patch
Patch004: backport-Take-2-fixing-the-placement-of-json_tokener_error_memory.patch
Patch005: backport-Issue-867-disallow-control-characters-in-strict-mode.patch
Patch006: backport-Fix-the-expected-output-for-test_parse.patch
Patch007: backport-Fix-issue-875-cast-to-unsigned-char-so-bytes-above-0.patch
Patch6001: backport-fix-issue-854-Set-error-json_tokener_error_memory-in.patch
Patch6002: backport-Handle-yet-another-out-of-memory-condition.patch
Patch6003: backport-Issue-857-fix-a-few-places-where-json_tokener-should.patch
Patch6004: backport-Take-2-fixing-the-placement-of-json_tokener_error_memory.patch
Patch6005: backport-Issue-867-disallow-control-characters-in-strict-mode.patch
Patch6006: backport-Fix-the-expected-output-for-test_parse.patch
Patch6007: backport-Fix-issue-875-cast-to-unsigned-char-so-bytes-above-0.patch
Patch6008: backport-Fix-the-apps-json_parse-s-strict-option-so-it-actual.patch
%description
JSON-C implements a reference counting object model that allows you
@ -109,10 +110,19 @@ end
%doc %{_pkgdocdir}
%changelog
* Fri Dec 06 2024 sunhai <sunhai10@huawei.com> - 0.17-6
- Type:bugfix
- ID:NA
- SUG:NA
- DESC: Fix the apps/json_parse "-s" (strict) option so it actually does something, and default to non-strict.
* Wed Dec 04 2024 yueyuankun <yueyuankun@kylinos.cn> - 0.17-5
- Disallow control characters in strict mode
- Fix the expected output for test_parse
- Fix causing the strict-mode control characters check to incorrectly trigger
- Type:bugfix
- ID:NA
- SUG:NA
- DESC: Disallow control characters in strict mode
Fix the expected output for test_parse
Fix causing the strict-mode control characters check to incorrectly trigger
* Tue Sep 24 2024 sunhai <sunhai10@huawei.com> - 0.17-4
- Take 2 fixing the placement of json_tokener_error_memory in the enum.