Compare commits
No commits in common. "35150a2635c1930d072aa05b2ede52bb24e9e7ee" and "f40bec6e6ff54c35d89af6ffc8297183c3332326" have entirely different histories.
35150a2635
...
f40bec6e6f
@ -1,59 +0,0 @@
|
|||||||
From 8269bc2bc289e9d343bae51cdf6d23ef0950e001 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Florin Malita <fmalita@gmail.com>
|
|
||||||
Date: Tue, 15 May 2018 22:48:07 -0400
|
|
||||||
Subject: [PATCH] Prevent int underflow when parsing exponents
|
|
||||||
|
|
||||||
When parsing negative exponents, the current implementation takes
|
|
||||||
precautions for |exp| to not underflow int.
|
|
||||||
|
|
||||||
But that is not sufficient: later on [1], |exp + expFrac| is also
|
|
||||||
stored to an int - so we must ensure that the sum stays within int
|
|
||||||
representable values.
|
|
||||||
|
|
||||||
Update the exp clamping logic to take expFrac into account.
|
|
||||||
|
|
||||||
[1] https://github.com/Tencent/rapidjson/blob/master/include/rapidjson/reader.h#L1690
|
|
||||||
---
|
|
||||||
include/rapidjson/reader.h | 11 ++++++++++-
|
|
||||||
test/unittest/readertest.cpp | 1 +
|
|
||||||
2 files changed, 11 insertions(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/include/rapidjson/reader.h b/include/rapidjson/reader.h
|
|
||||||
index 7441eda4..f95aef42 100644
|
|
||||||
--- a/include/rapidjson/reader.h
|
|
||||||
+++ b/include/rapidjson/reader.h
|
|
||||||
@@ -1632,9 +1632,18 @@ private:
|
|
||||||
if (RAPIDJSON_LIKELY(s.Peek() >= '0' && s.Peek() <= '9')) {
|
|
||||||
exp = static_cast<int>(s.Take() - '0');
|
|
||||||
if (expMinus) {
|
|
||||||
+ // (exp + expFrac) must not underflow int => we're detecting when -exp gets
|
|
||||||
+ // dangerously close to INT_MIN (a pessimistic next digit 9 would push it into
|
|
||||||
+ // underflow territory):
|
|
||||||
+ //
|
|
||||||
+ // -(exp * 10 + 9) + expFrac >= INT_MIN
|
|
||||||
+ // <=> exp <= (expFrac - INT_MIN - 9) / 10
|
|
||||||
+ RAPIDJSON_ASSERT(expFrac <= 0);
|
|
||||||
+ int maxExp = (expFrac + 2147483639) / 10;
|
|
||||||
+
|
|
||||||
while (RAPIDJSON_LIKELY(s.Peek() >= '0' && s.Peek() <= '9')) {
|
|
||||||
exp = exp * 10 + static_cast<int>(s.Take() - '0');
|
|
||||||
- if (exp >= 214748364) { // Issue #313: prevent overflow exponent
|
|
||||||
+ if (RAPIDJSON_UNLIKELY(exp > maxExp)) {
|
|
||||||
while (RAPIDJSON_UNLIKELY(s.Peek() >= '0' && s.Peek() <= '9')) // Consume the rest of exponent
|
|
||||||
s.Take();
|
|
||||||
}
|
|
||||||
diff --git a/test/unittest/readertest.cpp b/test/unittest/readertest.cpp
|
|
||||||
index e5308019..c4800b93 100644
|
|
||||||
--- a/test/unittest/readertest.cpp
|
|
||||||
+++ b/test/unittest/readertest.cpp
|
|
||||||
@@ -242,6 +242,7 @@ static void TestParseDouble() {
|
|
||||||
TEST_DOUBLE(fullPrecision, "1e-214748363", 0.0); // Maximum supported negative exponent
|
|
||||||
TEST_DOUBLE(fullPrecision, "1e-214748364", 0.0);
|
|
||||||
TEST_DOUBLE(fullPrecision, "1e-21474836311", 0.0);
|
|
||||||
+ TEST_DOUBLE(fullPrecision, "1.00000000001e-2147483638", 0.0);
|
|
||||||
TEST_DOUBLE(fullPrecision, "0.017976931348623157e+310", 1.7976931348623157e+308); // Max double in another form
|
|
||||||
|
|
||||||
// Since
|
|
||||||
--
|
|
||||||
2.20.1
|
|
||||||
|
|
||||||
@ -1,12 +0,0 @@
|
|||||||
diff -Nuar rapidjson-1.1.0.org/include/rapidjson/rapidjson.h rapidjson-1.1.0.sw/include/rapidjson/rapidjson.h
|
|
||||||
--- rapidjson-1.1.0.org/include/rapidjson/rapidjson.h 2022-05-09 16:56:54.370734000 +0800
|
|
||||||
+++ rapidjson-1.1.0.sw/include/rapidjson/rapidjson.h 2022-05-09 16:58:52.180734000 +0800
|
|
||||||
@@ -234,7 +234,7 @@
|
|
||||||
// Detect with architecture macros
|
|
||||||
# elif defined(__sparc) || defined(__sparc__) || defined(_POWER) || defined(__powerpc__) || defined(__ppc__) || defined(__hpux) || defined(__hppa) || defined(_MIPSEB) || defined(_POWER) || defined(__s390__)
|
|
||||||
# define RAPIDJSON_ENDIAN RAPIDJSON_BIGENDIAN
|
|
||||||
-# elif defined(__i386__) || defined(__alpha__) || defined(__ia64) || defined(__ia64__) || defined(_M_IX86) || defined(_M_IA64) || defined(_M_ALPHA) || defined(__amd64) || defined(__amd64__) || defined(_M_AMD64) || defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) || defined(__bfin__)
|
|
||||||
+# elif defined(__i386__) || defined(__alpha__) || defined(__sw_64__) || defined(__ia64) || defined(__ia64__) || defined(_M_IX86) || defined(_M_IA64) || defined(_M_ALPHA) || defined(_M_SW_64) || defined(__amd64) || defined(__amd64__) || defined(_M_AMD64) || defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) || defined(__bfin__)
|
|
||||||
# define RAPIDJSON_ENDIAN RAPIDJSON_LITTLEENDIAN
|
|
||||||
# elif defined(_MSC_VER) && defined(_M_ARM)
|
|
||||||
# define RAPIDJSON_ENDIAN RAPIDJSON_LITTLEENDIAN
|
|
||||||
@ -1,14 +1,12 @@
|
|||||||
%global debug_package %{nil}
|
%global debug_package %{nil}
|
||||||
Name: rapidjson
|
Name: rapidjson
|
||||||
Version: 1.1.0
|
Version: 1.1.0
|
||||||
Release: 12
|
Release: 9
|
||||||
Summary: small & selft-contained fast JSON parser and generator for C++
|
Summary: small & selft-contained fast JSON parser and generator for C++
|
||||||
License: MIT
|
License: MIT
|
||||||
URL: http://miloyip.github.io/rapidjson
|
URL: http://miloyip.github.io/rapidjson
|
||||||
Source0: https://github.com/miloyip/rapidjson/archive/v%{version}.tar.gz#/rapidjson-%{version}.tar.gz
|
Source0: https://github.com/miloyip/rapidjson/archive/v%{version}.tar.gz#/rapidjson-%{version}.tar.gz
|
||||||
Patch0000: rapidjson-1.1.0-do_not_include_gtest_src_dir.patch
|
Patch0000: rapidjson-1.1.0-do_not_include_gtest_src_dir.patch
|
||||||
Patch0001: rapidjson-1.1.0-sw.patch
|
|
||||||
Patch0002: backport-CVE-2024-38517.patch
|
|
||||||
BuildRequires: cmake gcc-c++ gtest-devel valgrind
|
BuildRequires: cmake gcc-c++ gtest-devel valgrind
|
||||||
|
|
||||||
%description
|
%description
|
||||||
@ -42,12 +40,7 @@ Obsoletes: rapidjson-doc < %{version}-%{release}
|
|||||||
This package provides docs for rapidjson.
|
This package provides docs for rapidjson.
|
||||||
|
|
||||||
%prep
|
%prep
|
||||||
%setup -n rapidjson-%{version}
|
%autosetup -n rapidjson-%{version} -p1
|
||||||
%patch0 -p1
|
|
||||||
%ifarch sw_64
|
|
||||||
%patch1 -p1
|
|
||||||
%endif
|
|
||||||
%patch2 -p1
|
|
||||||
install -d build
|
install -d build
|
||||||
for _file in "license.txt" $(%{_bindir}/find example -type f -name '*.c*')
|
for _file in "license.txt" $(%{_bindir}/find example -type f -name '*.c*')
|
||||||
do
|
do
|
||||||
@ -73,8 +66,8 @@ cd -
|
|||||||
%{__cp} -a CHANGELOG.md readme*.md examples %{buildroot}%{_pkgdocdir}
|
%{__cp} -a CHANGELOG.md readme*.md examples %{buildroot}%{_pkgdocdir}
|
||||||
%{_bindir}/find %{buildroot} -type f -name 'CMake*.txt' -print0 | \
|
%{_bindir}/find %{buildroot} -type f -name 'CMake*.txt' -print0 | \
|
||||||
%{_bindir}/xargs -0 %{__rm} -fv
|
%{_bindir}/xargs -0 %{__rm} -fv
|
||||||
hardlink -v %{buildroot}%{_includedir}
|
%{_sbindir}/hardlink -v %{buildroot}%{_includedir}
|
||||||
hardlink -v %{buildroot}%{_pkgdocdir}
|
%{_sbindir}/hardlink -v %{buildroot}%{_pkgdocdir}
|
||||||
|
|
||||||
%check
|
%check
|
||||||
CTEST_EXCLUDE=".*valgrind.*"
|
CTEST_EXCLUDE=".*valgrind.*"
|
||||||
@ -95,14 +88,5 @@ cd -
|
|||||||
%doc %{_pkgdocdir}
|
%doc %{_pkgdocdir}
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
* Thu Jul 11 2024 zhangxianting <zhangxianting@uniontech.com> - 1.1.0-12
|
|
||||||
- Fix CVE-2024-38517
|
|
||||||
|
|
||||||
* Wed Oct 26 2022 wuzx<wuzx1226@qq.com> - 1.1.0-11
|
|
||||||
- Add sw64 architecture
|
|
||||||
|
|
||||||
* Wed Jul 29 2020 lingsheng <lingsheng@huawei.com> - 1.1.0-10
|
|
||||||
- Not use hardlink absolute path
|
|
||||||
|
|
||||||
* Mon Jun 8 2020 Jeffery.Gao <gaojianxing@huawei.com> - 1.1.0-9
|
* Mon Jun 8 2020 Jeffery.Gao <gaojianxing@huawei.com> - 1.1.0-9
|
||||||
- Package init
|
- Package init
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
version_control: github
|
version-control: github
|
||||||
src_repo: Tencent/rapidjson
|
src_repo: Tencent/rapidjson
|
||||||
tag_prefix: "^v"
|
tag_prefix: v^
|
||||||
separator: .
|
seperator: .
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user