From 1fee094c8bb05306812ef13906a314a46aa5815b Mon Sep 17 00:00:00 2001 From: wuzhaomin Date: Fri, 10 May 2024 17:31:17 +0800 Subject: [PATCH 1/2] fix: print int without decimal places --- ...print-int-without-decimal-places-630.patch | 26 +++++++++++++++++++ cjson.spec | 10 ++++--- 2 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 backport-fix-print-int-without-decimal-places-630.patch diff --git a/backport-fix-print-int-without-decimal-places-630.patch b/backport-fix-print-int-without-decimal-places-630.patch new file mode 100644 index 0000000..d87b70c --- /dev/null +++ b/backport-fix-print-int-without-decimal-places-630.patch @@ -0,0 +1,26 @@ +From d321fa9e6e574ff93518f6384865b9af0a4a4afc Mon Sep 17 00:00:00 2001 +From: AlexanderVasiljev <48011002+AlexanderVasiljev@users.noreply.github.com> +Date: Wed, 19 Jan 2022 05:30:31 +0300 +Subject: [PATCH] fix: print int without decimal places (#630) + +--- + cJSON.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/cJSON.c b/cJSON.c +index 3063f74..c78aac6 100644 +--- a/cJSON.c ++++ b/cJSON.c +@@ -562,6 +562,10 @@ static cJSON_bool print_number(const cJSON * const item, printbuffer * const out + { + length = sprintf((char*)number_buffer, "null"); + } ++ else if(d == (double)item->valueint) ++ { ++ length = sprintf((char*)number_buffer, "%d", item->valueint); ++ } + else + { + /* Try 15 decimal places of precision to avoid nonsignificant nonzero digits */ +-- + diff --git a/cjson.spec b/cjson.spec index 95bb4c8..d3a396d 100644 --- a/cjson.spec +++ b/cjson.spec @@ -1,6 +1,6 @@ Name: cjson Version: 1.7.15 -Release: 6 +Release: 7 Summary: Ultralightweight JSON parser in ANSI C License: MIT and ASL 2.0 @@ -10,8 +10,9 @@ Source0: https://github.com/DaveGamble/cJSON/archive/refs/tags/v1.7.15.ta Patch0001: backport-CVE-2023-50471_50472.patch Patch0002: backport-fix-potential-memory-leak-in-merge_patch.patch Patch0003: CVE-2024-31755.patch -Patch0004: Fix-a-null-pointer-crash-in-cJSON_ReplaceItemViaPoin.patch -Patch0005: backport-fix-add-allocate-check-for-replace_item_in_object-67.patch +Patch0004: Fix-a-null-pointer-crash-in-cJSON_ReplaceItemViaPoin.patch +Patch0005: backport-fix-add-allocate-check-for-replace_item_in_object-67.patch +Patch0006: cjson/backport-fix-print-int-without-decimal-places-630.patch BuildRequires: gcc BuildRequires: cmake @@ -58,6 +59,9 @@ rm -f %{buildroot}%{_libdir}/cmake/cJSON/*.cmake %{_includedir}/cjson/ %changelog +* Fri May 10 2024 wuzhaomin - 1.7.15-7 +- Fix print int without decimal places + * Wed May 8 2024 wuzhaomin - 1.7.15-6 - add allocate check for replace_item_in_object -- Gitee From 75da6dd54b322852492ae2e86186c98dd66a3303 Mon Sep 17 00:00:00 2001 From: wuzhaomin Date: Fri, 10 May 2024 17:35:40 +0800 Subject: [PATCH 2/2] --amend --- cjson.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cjson.spec b/cjson.spec index d3a396d..07d0f90 100644 --- a/cjson.spec +++ b/cjson.spec @@ -12,7 +12,7 @@ Patch0002: backport-fix-potential-memory-leak-in-merge_patch.patch Patch0003: CVE-2024-31755.patch Patch0004: Fix-a-null-pointer-crash-in-cJSON_ReplaceItemViaPoin.patch Patch0005: backport-fix-add-allocate-check-for-replace_item_in_object-67.patch -Patch0006: cjson/backport-fix-print-int-without-decimal-places-630.patch +Patch0006: backport-fix-print-int-without-decimal-places-630.patch BuildRequires: gcc BuildRequires: cmake -- Gitee