diff --git a/0001-Parse-large-floats-as-infinity-1349-1353.patch b/0001-Parse-large-floats-as-infinity-1349-1353.patch deleted file mode 100644 index 28909252066d1137c45b4531848132712bf04e90..0000000000000000000000000000000000000000 --- a/0001-Parse-large-floats-as-infinity-1349-1353.patch +++ /dev/null @@ -1,102 +0,0 @@ -From 2d55c7445ffedf30db62231f223137ef02e611a9 Mon Sep 17 00:00:00 2001 -From: Tero Kinnunen -Date: Wed, 15 Dec 2021 04:00:28 +0200 -Subject: [PATCH] Parse large floats as infinity (#1349) (#1353) - -Return 1.9.1 functionality where values too large to fit in -double are converted to positive or negative infinity. - -Commit 645cd04 changed functionality so that large floats cause -parse error, while version 1.9.1 accepted them as infinite. -This is problematic because writer outputs infinity values -as `1e+9999`, which could no longer be parsed back. - -Fixed also legacy Reader even though it did not parse large values -even before breaking change, due to problematic output/parse asymmetry. - -`>>` operator sets value to numeric_limits::max/lowest value if -representation is too large to fit to double. [1][2] In macos -value appears to be parsed to infinity. - -> | value in *val* | description | -> |--------------------------|-------------| -> | numeric_limits::max() | The sequence represents a value too large for the type of val | -> | numeric_limits::lowest() | The sequence represents a value too large negative for the type of val | - -[1] https://www.cplusplus.com/reference/istream/istream/operator%3E%3E/ -[2] https://www.cplusplus.com/reference/locale/num_get/get/ - -Signed-off-by: Tero Kinnunen - -Co-authored-by: Tero Kinnunen ---- - src/lib_json/json_reader.cpp | 18 +++++++++++++++--- - test/data/legacy_test_real_13.expected | 3 +++ - test/data/legacy_test_real_13.json | 1 + - 3 files changed, 19 insertions(+), 3 deletions(-) - create mode 100644 test/data/legacy_test_real_13.expected - create mode 100644 test/data/legacy_test_real_13.json - -diff --git a/src/lib_json/json_reader.cpp b/src/lib_json/json_reader.cpp -index a6a3f4e..896bf1b 100644 ---- a/src/lib_json/json_reader.cpp -+++ b/src/lib_json/json_reader.cpp -@@ -12,6 +12,7 @@ - #endif // if !defined(JSON_IS_AMALGAMATION) - #include - #include -+#include - #include - #include - #include -@@ -600,9 +601,15 @@ bool Reader::decodeDouble(Token& token, Value& decoded) { - double value = 0; - String buffer(token.start_, token.end_); - IStringStream is(buffer); -- if (!(is >> value)) -- return addError( -+ if (!(is >> value)) { -+ if (value == std::numeric_limits::max()) -+ value = std::numeric_limits::infinity(); -+ else if (value == std::numeric_limits::lowest()) -+ value = -std::numeric_limits::infinity(); -+ else if (!std::isinf(value)) -+ return addError( - "'" + String(token.start_, token.end_) + "' is not a number.", token); -+ } - decoded = value; - return true; - } -@@ -1647,7 +1654,12 @@ bool OurReader::decodeDouble(Token& token, Value& decoded) { - const String buffer(token.start_, token.end_); - IStringStream is(buffer); - if (!(is >> value)) { -- return addError( -+ if (value == std::numeric_limits::max()) -+ value = std::numeric_limits::infinity(); -+ else if (value == std::numeric_limits::lowest()) -+ value = -std::numeric_limits::infinity(); -+ else if (!std::isinf(value)) -+ return addError( - "'" + String(token.start_, token.end_) + "' is not a number.", token); - } - decoded = value; -diff --git a/test/data/legacy_test_real_13.expected b/test/data/legacy_test_real_13.expected -new file mode 100644 -index 0000000..8d3f03f ---- /dev/null -+++ b/test/data/legacy_test_real_13.expected -@@ -0,0 +1,3 @@ -+.=[] -+.[0]=-inf -+.[1]=inf -diff --git a/test/data/legacy_test_real_13.json b/test/data/legacy_test_real_13.json -new file mode 100644 -index 0000000..287258a ---- /dev/null -+++ b/test/data/legacy_test_real_13.json -@@ -0,0 +1 @@ -+[-1e+9999, 1e+9999] --- -2.42.0.windows.2 - diff --git a/0001-Use-default-rather-than-hard-coded-8-for-maximum-agg.patch b/0001-Use-default-rather-than-hard-coded-8-for-maximum-agg.patch deleted file mode 100644 index d72236a28314a99b35005c5e42d82e5580083931..0000000000000000000000000000000000000000 --- a/0001-Use-default-rather-than-hard-coded-8-for-maximum-agg.patch +++ /dev/null @@ -1,126 +0,0 @@ -From 42e892d96e47b1f6e29844cc705e148ec4856448 Mon Sep 17 00:00:00 2001 -From: Jessica Clarke -Date: Wed, 12 Jan 2022 21:27:16 +0000 -Subject: [PATCH] Use default rather than hard-coded 8 for maximum aggregate - member alignment (#1378) - -On CHERI, and thus Arm's Morello prototype, pointers are represented as -hardware capabilities. These capabilities are comprised of not just an -integer address, as is the representation for traditional pointers, but -also bounds, permissions and other metadata, plus a tag bit used as the -validity bit, which provides fine-grained spatial and referential safety -for C and C++ in hardware. This tag bit is not part of the data itself -and is instead kept on the side, flowing with the capability between -registers and the memory subsystem, and any attempt to amplify the -privilege of or corrupt a capability clears this tag (or, in some cases, -traps), rendering them impossible to forge; you can only create -capabilities that are (possibly trivial) subsets of existing ones. - -When the capability is stored in memory, this tag bit needs to be -preserved, which is done through the use of tagged memory. Every -capability-sized word gains an additional non-addressable (from the -CPU's perspective; depending on the implementation the tag bits may be -stored in a small block of memory carved out of normal DRAM that the CPU -is blocked from accessing) bit. This means that capabilities can only be -stored to aligned locations; attempting to store them to unaligned -locations will trap with an alignment fault or, if you end up using a -memcpy call, will copy the raw bytes of the capability's representation -but lose the tag, so when it is eventually loaded back as a capability -and dereferenced it will fault. - -Since, on 64-bit architectures, our capabilities, used to implement C -language pointers, are 128-bit quantities, this means they need 16-byte -alignment. Currently the various #pragma pack directives, used to work -around (extremely broken and bogus) code that includes jsoncpp in a -context where the maximum alignment has been overridden, hard-code 8 as -the maximum alignment to use, and so do not sufficiently align CHERI / -Morello capabilities on 64-bit architectures. On Windows x64, the -default is also not 8 but 16 (ARM64 is supposedly 8), so this is -slightly dodgy to do there too, but in practice likely not an issue so -long as you don't use any 128-bit types there. - -Instead of hard-coding a width, use a directive that resets the packing -back to the default. Unfortunately, whilst GCC and Clang both accept -using #pragma pack(push, 0) as shorthand like for any non-zero value, -MSVC does not, so this needs to be two directives. ---- - include/json/allocator.h | 3 ++- - include/json/json_features.h | 3 ++- - include/json/reader.h | 3 ++- - include/json/value.h | 3 ++- - include/json/writer.h | 3 ++- - 5 files changed, 10 insertions(+), 5 deletions(-) - -diff --git a/include/json/allocator.h b/include/json/allocator.h -index 95ef8a5..7540642 100644 ---- a/include/json/allocator.h -+++ b/include/json/allocator.h -@@ -9,7 +9,8 @@ - #include - #include - --#pragma pack(push, 8) -+#pragma pack(push) -+#pragma pack() - - namespace Json { - template class SecureAllocator { -diff --git a/include/json/json_features.h b/include/json/json_features.h -index 7c7e9f5..e4a61d6 100644 ---- a/include/json/json_features.h -+++ b/include/json/json_features.h -@@ -10,7 +10,8 @@ - #include "forwards.h" - #endif // if !defined(JSON_IS_AMALGAMATION) - --#pragma pack(push, 8) -+#pragma pack(push) -+#pragma pack() - - namespace Json { - -diff --git a/include/json/reader.h b/include/json/reader.h -index be0d767..46975d8 100644 ---- a/include/json/reader.h -+++ b/include/json/reader.h -@@ -23,7 +23,8 @@ - #pragma warning(disable : 4251) - #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING) - --#pragma pack(push, 8) -+#pragma pack(push) -+#pragma pack() - - namespace Json { - -diff --git a/include/json/value.h b/include/json/value.h -index 0edeb05..57ecb13 100644 ---- a/include/json/value.h -+++ b/include/json/value.h -@@ -53,7 +53,8 @@ - #pragma warning(disable : 4251 4275) - #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING) - --#pragma pack(push, 8) -+#pragma pack(push) -+#pragma pack() - - /** \brief JSON (JavaScript Object Notation). - */ -diff --git a/include/json/writer.h b/include/json/writer.h -index 03f9906..7d8cf4d 100644 ---- a/include/json/writer.h -+++ b/include/json/writer.h -@@ -20,7 +20,8 @@ - #pragma warning(disable : 4251) - #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING) - --#pragma pack(push, 8) -+#pragma pack(push) -+#pragma pack() - - namespace Json { - --- -2.42.0.windows.2 - diff --git a/BUILD.gn b/BUILD.gn index 87d400b3e90a0917ec6847a12f76ffd017a2974e..b2cf51fc7a7e9a0a2c1435f0414c4ab3043158ea 100755 --- a/BUILD.gn +++ b/BUILD.gn @@ -17,18 +17,12 @@ import("//build/ohos.gni") action("jsoncpp_install_action") { script = "//third_party/jsoncpp/install.py" outputs = [ - "${target_gen_dir}/jsoncpp-1.9.5/src/lib_json/json_reader.cpp", - "${target_gen_dir}/jsoncpp-1.9.5/src/lib_json/json_value.cpp", - "${target_gen_dir}/jsoncpp-1.9.5/src/lib_json/json_writer.cpp", + "${target_gen_dir}/jsoncpp-1.9.6/src/lib_json/json_reader.cpp", + "${target_gen_dir}/jsoncpp-1.9.6/src/lib_json/json_value.cpp", + "${target_gen_dir}/jsoncpp-1.9.6/src/lib_json/json_writer.cpp", ] - inputs = [ "//third_party/jsoncpp/jsoncpp-1.9.5.tar.gz" ] - inputs += [ - "0001-Parse-large-floats-as-infinity-1349-1353.patch", - "0001-Use-default-rather-than-hard-coded-8-for-maximum-agg.patch", - "Fix_error_whenparses_the_value_of_5E-324_with_libc++.patch", - "Fix_out-of-bounds_read.patch", - ] + inputs = [ "//third_party/jsoncpp/jsoncpp-1.9.6.tar.gz" ] args = [ "--gen-dir", @@ -61,7 +55,7 @@ config("flag_config") { config("jsoncpp_public_config") { include_dirs = [ get_label_info(":jsoncpp_install_action", "target_gen_dir") + - "/jsoncpp-1.9.5/include" ] + "/jsoncpp-1.9.6/include" ] } ohos_shared_library("jsoncpp") { diff --git a/Fix_error_whenparses_the_value_of_5E-324_with_libc++.patch b/Fix_error_whenparses_the_value_of_5E-324_with_libc++.patch deleted file mode 100644 index 62e3c99443418680818c3115edcbc4f120b4605a..0000000000000000000000000000000000000000 --- a/Fix_error_whenparses_the_value_of_5E-324_with_libc++.patch +++ /dev/null @@ -1,18 +0,0 @@ -diff --git a/src/lib_json/json_reader.cpp b/src/lib_json/json_reader.cpp -index 896bf1b..6624cb0 100644 ---- a/src/lib_json/json_reader.cpp -+++ b/src/lib_json/json_reader.cpp -@@ -1654,6 +1654,12 @@ bool OurReader::decodeDouble(Token& token, Value& decoded) { - const String buffer(token.start_, token.end_); - IStringStream is(buffer); - if (!(is >> value)) { -+ // the value could be lower than numeric_limits::min(), in this situtation we should return the value with the gurantee -+ // of conversion which has been performed and no occurances of range error. -+ if ((value > 0 && value < std::numeric_limits::min()) || (value < 0 && value > -std::numeric_limits::min())) { -+ decoded = value; -+ return true; -+ } - if (value == std::numeric_limits::max()) - value = std::numeric_limits::infinity(); - else if (value == std::numeric_limits::lowest()) - diff --git a/Fix_out-of-bounds_read.patch b/Fix_out-of-bounds_read.patch deleted file mode 100644 index 6d979317d2dcf18a2e024d195e32afbe49ff45d1..0000000000000000000000000000000000000000 --- a/Fix_out-of-bounds_read.patch +++ /dev/null @@ -1,21 +0,0 @@ -diff --git a/src/lib_json/json_reader.cpp b/src/lib_json/json_reader.cpp ---- a/src/lib_json/json_reader.cpp -+++ b/src/lib_json/json_reader.cpp -@@ -773,7 +773,7 @@ - while (current < location && current != end_) { - Char c = *current++; - if (c == '\r') { -- if (*current == '\n') -+ if (current != end_ && *current == '\n') - ++current; - lastLineStart = current; - ++line; -@@ -1826,7 +1826,7 @@ - while (current < location && current != end_) { - Char c = *current++; - if (c == '\r') { -- if (*current == '\n') -+ if (current != end_ && *current == '\n') - ++current; - lastLineStart = current; - ++line; diff --git a/README.OpenSource b/README.OpenSource index c4e0fbcbfc8951d4f6aba1fa517c8bad86236284..8b13f263e04e3ed941fc6b3a88b2e07202c8f6e2 100644 --- a/README.OpenSource +++ b/README.OpenSource @@ -3,9 +3,9 @@ "Name": "openEuler:jsoncpp", "License": "MIT License", "License File": "Copyright", - "Version Number": "1.9.5-5.oe2203sp3", + "Version Number": "1.9.6", "Owner": "jameslee@huawei.com", - "Upstream URL": "https://repo.openeuler.org/openEuler-22.03-LTS-SP3/source/Packages/jsoncpp-1.9.5-5.oe2203sp3.src.rpm", + "Upstream URL": "https://github.com/open-source-parsers/jsoncpp/-/archive/resf/tags/1.9.6.zip", "Description": "JsonCpp is a C++ library that allows manipulating JSON values, including serialization and deserialization to and from strings. It can also preserve existing comment in unserialization/serialization steps, making it a convenient format to store user input files." } ] diff --git a/bundle.json b/bundle.json index b230f1e0e6767355548a8a75f3522bd6e127e85a..c72d358954f8e092437d127cb0f4da2df066f2f5 100644 --- a/bundle.json +++ b/bundle.json @@ -43,7 +43,7 @@ "json/value.h", "json/version.h" ], - "header_base": "${root_gen_dir}/third_party/jsoncpp/jsoncpp-1.9.5/include" + "header_base": "${root_gen_dir}/third_party/jsoncpp/jsoncpp-1.9.6/include" } }, { diff --git a/install.py b/install.py index 9167054facac12bff583012cdecf588947af0f35..0295d6337cfe7da5d17ac11aa12d6dd0db99b9b0 100755 --- a/install.py +++ b/install.py @@ -50,12 +50,7 @@ def apply_patch(patch_file, target_dir): def do_patch(args, target_dir): - patch_file = [ - "Fix_error_whenparses_the_value_of_5E-324_with_libc++.patch", - "0001-Parse-large-floats-as-infinity-1349-1353.patch", - "0001-Use-default-rather-than-hard-coded-8-for-maximum-agg.patch", - "Fix_out-of-bounds_read.patch" - ] + patch_file = [] for patch in patch_file: file_path = os.path.join(args.source_file, patch) @@ -82,8 +77,8 @@ def main(): libpng_path.add_argument('--gen-dir', help='generate path of jsoncpp') libpng_path.add_argument('--source-file', help='jsoncpp source compressed dir') args = libpng_path.parse_args() - tar_file_path = os.path.join(args.source_file, "jsoncpp-1.9.5.tar.gz") - tmp_dir = os.path.join(THIS_FILE_PATH, "jsoncpp-1.9.5") + tar_file_path = os.path.join(args.source_file, "jsoncpp-1.9.6.tar.gz") + tmp_dir = os.path.join(THIS_FILE_PATH, "jsoncpp-1.9.6") untar_file(tar_file_path, tmp_dir, THIS_FILE_PATH) do_patch(args, tmp_dir) do_copy(tmp_dir, args.gen_dir) diff --git a/jsoncpp-1.9.5.tar.gz b/jsoncpp-1.9.5.tar.gz deleted file mode 100644 index 35052afe734d0a08b53b2448fc3a1b8b8b977331..0000000000000000000000000000000000000000 Binary files a/jsoncpp-1.9.5.tar.gz and /dev/null differ diff --git a/jsoncpp-1.9.6.tar.gz b/jsoncpp-1.9.6.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..2d4c7f2d4891f6d9e60b8a69e0e1e79566f6bf6b Binary files /dev/null and b/jsoncpp-1.9.6.tar.gz differ