Accepting request 827515 from devel:libraries:c_c++
- update to 0.15: * Deprecate `array_list_new()` in favor of `array_list_new2()` * Remove the THIS_FUNCTION_IS_DEPRECATED define. * Remove config.h.win32 * Add a `JSON_TOKENER_ALLOW_TRAILING_CHARS` flag to allow multiple objects to be parsed even when `JSON_TOKENER_STRICT` is set. * Add `json_object_new_array_ext(int)` and `array_list_new_2(int)` to allow arrays to be allocated with the exact size needed, when known. * Add `json_object_array_shrink()` (and `array_list_shrink()`) and use it in json_tokener to minimize the amount of memory used. * Add a json_parse binary, for use in testing changes (not installed, but available in the apps directory). * Split the internal json_object structure into several sub-types, one for each json_type (json_object_object, json_object_string, etc...). This improves memory usage and speed, with the benchmark under bench/ report 5.8% faster test time and 6%(max RSS)-12%(peak heap) less memory usage. Memory used just for json_object structures decreased 27%, so use cases with fewer arrays and/or strings would benefit more. * Minimize memory usage in array handling in json_tokener by shrinking arrays to the exact number of elements parsed. On bench/ benchmark: 9% faster test time, 39%(max RSS)-50%(peak heap) less memory usage. Add json_object_array_shrink() and array_list_shrink() functions. * #616 - Parsing of surrogate pairs in unicode escapes now properly handles incremental parsing. * Fix incremental parsing of numbers, especially those with exponents, e.g. so parsing "[0", "e+", "-]" now properly returns an error. Strict mode now rejects missing exponents ("0e"). * Successfully return number objects at the top level even when they are followed by a "-", "." or "e". This makes parsing things like "123-45" OBS-URL: https://build.opensuse.org/request/show/827515 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/json-c?expand=0&rev=26
This commit is contained in:
commit
324d7914db
@ -1,131 +0,0 @@
|
||||
From eec4df641cbce416c86f2e7d6c740d85b8906451 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Bj=C3=B6rn=20Esser?= <besser82@fedoraproject.org>
|
||||
Date: Mon, 25 May 2020 13:03:31 +0200
|
||||
Subject: [PATCH] Detect broken RDRAND during initialization.
|
||||
|
||||
Some CPUs advertise RDRAND in CPUID, but return
|
||||
0xFFFFFFFF unconditionally. To avoid locking up
|
||||
later, test RDRAND during initialization, and if
|
||||
it returns 0xFFFFFFFF, mark it as nonexistent.
|
||||
|
||||
Also fix a possible segmentation fault in CPUID check.
|
||||
|
||||
This commit is a squashed backport of the following
|
||||
commits on the master branch:
|
||||
|
||||
* 0e5bbcaa162ac7850eb4fcd8f91391837d0efb50
|
||||
* 4d36b0287d3ab0912ba8a4790340ca099960b2b0
|
||||
* 80863140263be5f2dc630938ed8f0066f8a1ab43
|
||||
---
|
||||
random_seed.c | 66 ++++++++++++++++++++++++++++++++++++++-------------
|
||||
1 file changed, 49 insertions(+), 17 deletions(-)
|
||||
|
||||
diff --git a/random_seed.c b/random_seed.c
|
||||
index fc19e26d13..b5f8a0795e 100644
|
||||
--- a/random_seed.c
|
||||
+++ b/random_seed.c
|
||||
@@ -26,19 +26,8 @@
|
||||
static void do_cpuid(int regs[], int h)
|
||||
{
|
||||
/* clang-format off */
|
||||
- __asm__ __volatile__(
|
||||
-#if defined __x86_64__
|
||||
- "pushq %%rbx;\n"
|
||||
-#else
|
||||
- "pushl %%ebx;\n"
|
||||
-#endif
|
||||
- "cpuid;\n"
|
||||
-#if defined __x86_64__
|
||||
- "popq %%rbx;\n"
|
||||
-#else
|
||||
- "popl %%ebx;\n"
|
||||
-#endif
|
||||
- : "=a"(regs[0]), [ebx] "=r"(regs[1]), "=c"(regs[2]), "=d"(regs[3])
|
||||
+ __asm__ __volatile__("cpuid"
|
||||
+ : "=a"(regs[0]), "=b"(regs[1]), "=c"(regs[2]), "=d"(regs[3])
|
||||
: "a"(h));
|
||||
/* clang-format on */
|
||||
}
|
||||
@@ -54,12 +43,51 @@ static void do_cpuid(int regs[], int h)
|
||||
|
||||
#if HAS_X86_CPUID
|
||||
|
||||
+static int get_rdrand_seed(void);
|
||||
+
|
||||
+/* Valid values are -1 (haven't tested), 0 (no), and 1 (yes). */
|
||||
+static int _has_rdrand = -1;
|
||||
+
|
||||
static int has_rdrand(void)
|
||||
{
|
||||
- // CPUID.01H:ECX.RDRAND[bit 30] == 1
|
||||
+ if (_has_rdrand != -1)
|
||||
+ {
|
||||
+ return _has_rdrand;
|
||||
+ }
|
||||
+
|
||||
+ /* CPUID.01H:ECX.RDRAND[bit 30] == 1 */
|
||||
int regs[4];
|
||||
do_cpuid(regs, 1);
|
||||
- return (regs[2] & (1 << 30)) != 0;
|
||||
+ if (!(regs[2] & (1 << 30)))
|
||||
+ {
|
||||
+ _has_rdrand = 0;
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ /*
|
||||
+ * Some CPUs advertise RDRAND in CPUID, but return 0xFFFFFFFF
|
||||
+ * unconditionally. To avoid locking up later, test RDRAND here. If over
|
||||
+ * 3 trials RDRAND has returned the same value, declare it broken.
|
||||
+ * Example CPUs are AMD Ryzen 3000 series
|
||||
+ * and much older AMD APUs, such as the E1-1500
|
||||
+ * https://github.com/systemd/systemd/issues/11810
|
||||
+ * https://linuxreviews.org/RDRAND_stops_returning_random_values_on_older_AMD_CPUs_after_suspend
|
||||
+ */
|
||||
+ _has_rdrand = 0;
|
||||
+ int prev = get_rdrand_seed();
|
||||
+ for (int i = 0; i < 3; i++)
|
||||
+ {
|
||||
+ int temp = get_rdrand_seed();
|
||||
+ if (temp != prev)
|
||||
+ {
|
||||
+ _has_rdrand = 1;
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ prev = temp;
|
||||
+ }
|
||||
+
|
||||
+ return _has_rdrand;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -74,7 +102,7 @@ static int get_rdrand_seed(void)
|
||||
{
|
||||
DEBUG_SEED("get_rdrand_seed");
|
||||
int _eax;
|
||||
- // rdrand eax
|
||||
+ /* rdrand eax */
|
||||
/* clang-format off */
|
||||
__asm__ __volatile__("1: .byte 0x0F\n"
|
||||
" .byte 0xC7\n"
|
||||
@@ -114,7 +142,7 @@ static int get_rdrand_seed(void)
|
||||
DEBUG_SEED("get_rdrand_seed");
|
||||
int _eax;
|
||||
retry:
|
||||
- // rdrand eax
|
||||
+ /* rdrand eax */
|
||||
__asm _emit 0x0F __asm _emit 0xC7 __asm _emit 0xF0
|
||||
__asm jnc retry
|
||||
__asm mov _eax, eax
|
||||
@@ -188,6 +216,10 @@ static int get_dev_random_seed(void)
|
||||
|
||||
/* clang-format off */
|
||||
#include <windows.h>
|
||||
+
|
||||
+/* Caution: these blank lines must remain so clang-format doesn't reorder
|
||||
+ includes to put windows.h after wincrypt.h */
|
||||
+
|
||||
#include <wincrypt.h>
|
||||
/* clang-format on */
|
||||
#ifndef __GNUC__
|
@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:b377de08c9b23ca3b37d9a9828107dff1de5ce208ff4ebb35005a794f30c6870
|
||||
size 321677
|
3
json-c-0.15-20200726.tar.gz
Normal file
3
json-c-0.15-20200726.tar.gz
Normal file
@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:4ba9a090a42cf1e12b84c64e4464bb6fb893666841d5843cc5bef90774028882
|
||||
size 348261
|
@ -1,3 +1,46 @@
|
||||
-------------------------------------------------------------------
|
||||
Mon Aug 17 10:02:27 UTC 2020 - Dirk Mueller <dmueller@suse.com>
|
||||
|
||||
- update to 0.15:
|
||||
* Deprecate `array_list_new()` in favor of `array_list_new2()`
|
||||
* Remove the THIS_FUNCTION_IS_DEPRECATED define.
|
||||
* Remove config.h.win32
|
||||
* Add a `JSON_TOKENER_ALLOW_TRAILING_CHARS` flag to allow multiple objects
|
||||
to be parsed even when `JSON_TOKENER_STRICT` is set.
|
||||
* Add `json_object_new_array_ext(int)` and `array_list_new_2(int)` to allow
|
||||
arrays to be allocated with the exact size needed, when known.
|
||||
* Add `json_object_array_shrink()` (and `array_list_shrink()`) and use it in
|
||||
json_tokener to minimize the amount of memory used.
|
||||
* Add a json_parse binary, for use in testing changes (not installed, but
|
||||
available in the apps directory).
|
||||
* Split the internal json_object structure into several sub-types, one for
|
||||
each json_type (json_object_object, json_object_string, etc...).
|
||||
This improves memory usage and speed, with the benchmark under
|
||||
bench/ report 5.8% faster test time and 6%(max RSS)-12%(peak heap)
|
||||
less memory usage.
|
||||
Memory used just for json_object structures decreased 27%, so use cases
|
||||
with fewer arrays and/or strings would benefit more.
|
||||
* Minimize memory usage in array handling in json_tokener by shrinking
|
||||
arrays to the exact number of elements parsed. On bench/ benchmark:
|
||||
9% faster test time, 39%(max RSS)-50%(peak heap) less memory usage.
|
||||
Add json_object_array_shrink() and array_list_shrink() functions.
|
||||
* #616 - Parsing of surrogate pairs in unicode escapes now properly handles
|
||||
incremental parsing.
|
||||
* Fix incremental parsing of numbers, especially those with exponents, e.g.
|
||||
so parsing "[0", "e+", "-]" now properly returns an error.
|
||||
Strict mode now rejects missing exponents ("0e").
|
||||
* Successfully return number objects at the top level even when they are
|
||||
followed by a "-", "." or "e". This makes parsing things like "123-45"
|
||||
behave consistently with things like "123xyz".
|
||||
* #589 - Detect broken RDRAND during initialization; also, fix segfault
|
||||
in the CPUID check.
|
||||
* #592 - Fix integer overflows to prevert out of bounds write on large input.
|
||||
* Protect against division by zero in linkhash, when creaed with zero size.
|
||||
* #602 - Fix json_parse_uint64() internal error checking, leaving the retval
|
||||
untouched in more failure cases.
|
||||
* #614 - Prevent truncation when custom double formatters insert extra \0's
|
||||
- remove 0001-Detect-broken-RDRAND-during-initialization.patch (upstream)
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Jun 17 08:04:43 UTC 2020 - Dan Čermák <dcermak@suse.com>
|
||||
|
||||
|
@ -20,16 +20,14 @@
|
||||
%define libsoname %{libname}5
|
||||
%define oldlibname libjson
|
||||
Name: json-c
|
||||
Version: 0.14
|
||||
Version: 0.15
|
||||
Release: 0
|
||||
Summary: JSON implementation in C
|
||||
License: MIT
|
||||
Group: Development/Libraries/C and C++
|
||||
URL: https://github.com/json-c/json-c
|
||||
Source0: %{URL}/archive/%{name}-%{version}-20200419.tar.gz#/%{name}-%{version}.tar.gz
|
||||
Source0: https://github.com/json-c/json-c/archive/json-c-0.15-20200726.tar.gz
|
||||
Source1: baselibs.conf
|
||||
# fix for boo#1173022
|
||||
Patch0: https://patch-diff.githubusercontent.com/raw/json-c/json-c/pull/624.patch#/0001-Detect-broken-RDRAND-during-initialization.patch
|
||||
BuildRequires: cmake
|
||||
BuildRequires: fdupes
|
||||
BuildRequires: libtool
|
||||
@ -87,7 +85,7 @@ representation of JSON objects.
|
||||
This package includes the json-c documentation.
|
||||
|
||||
%prep
|
||||
%autosetup -p1
|
||||
%autosetup -p1 -n %{name}-json-c-0.15-20200726
|
||||
|
||||
%build
|
||||
%if 0%{?suse_version} <= 1110
|
||||
|
Loading…
x
Reference in New Issue
Block a user