Sync from SUSE:SLFO:Main cJSON revision 623042f7f2f14ec2723156ff082d429f
This commit is contained in:
commit
27a737c622
23
.gitattributes
vendored
Normal file
23
.gitattributes
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
## Default LFS
|
||||
*.7z filter=lfs diff=lfs merge=lfs -text
|
||||
*.bsp filter=lfs diff=lfs merge=lfs -text
|
||||
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
||||
*.gem filter=lfs diff=lfs merge=lfs -text
|
||||
*.gz filter=lfs diff=lfs merge=lfs -text
|
||||
*.jar filter=lfs diff=lfs merge=lfs -text
|
||||
*.lz filter=lfs diff=lfs merge=lfs -text
|
||||
*.lzma filter=lfs diff=lfs merge=lfs -text
|
||||
*.obscpio filter=lfs diff=lfs merge=lfs -text
|
||||
*.oxt filter=lfs diff=lfs merge=lfs -text
|
||||
*.pdf filter=lfs diff=lfs merge=lfs -text
|
||||
*.png filter=lfs diff=lfs merge=lfs -text
|
||||
*.rpm filter=lfs diff=lfs merge=lfs -text
|
||||
*.tbz filter=lfs diff=lfs merge=lfs -text
|
||||
*.tbz2 filter=lfs diff=lfs merge=lfs -text
|
||||
*.tgz filter=lfs diff=lfs merge=lfs -text
|
||||
*.ttf filter=lfs diff=lfs merge=lfs -text
|
||||
*.txz filter=lfs diff=lfs merge=lfs -text
|
||||
*.whl filter=lfs diff=lfs merge=lfs -text
|
||||
*.xz filter=lfs diff=lfs merge=lfs -text
|
||||
*.zip filter=lfs diff=lfs merge=lfs -text
|
||||
*.zst filter=lfs diff=lfs merge=lfs -text
|
60
cJSON-1.7.18-misc_tests.patch
Normal file
60
cJSON-1.7.18-misc_tests.patch
Normal file
@ -0,0 +1,60 @@
|
||||
From 5b502cdbfb21fbe5f6cf9ffbd2b96e4281a741e6 Mon Sep 17 00:00:00 2001
|
||||
From: Alanscut <wp_scut@163.com>
|
||||
Date: Thu, 9 May 2024 10:45:16 +0800
|
||||
Subject: [PATCH] feat: add tests for #842
|
||||
|
||||
Add some tests for setting NULL to deallocated pointers
|
||||
releated to #842 and #833
|
||||
---
|
||||
tests/CMakeLists.txt | 1 +
|
||||
tests/misc_tests.c | 18 ++++++++++++++++++
|
||||
2 files changed, 19 insertions(+)
|
||||
|
||||
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
|
||||
index c7592213..9e8962f6 100644
|
||||
--- a/tests/CMakeLists.txt
|
||||
+++ b/tests/CMakeLists.txt
|
||||
@@ -62,6 +62,7 @@ if(ENABLE_CJSON_TEST)
|
||||
|
||||
option(ENABLE_VALGRIND OFF "Enable the valgrind memory checker for the tests.")
|
||||
if (ENABLE_VALGRIND)
|
||||
+ add_compile_definitions(ENABLE_VALGRIND)
|
||||
find_program(MEMORYCHECK_COMMAND valgrind)
|
||||
if ("${MEMORYCHECK_COMMAND}" MATCHES "MEMORYCHECK_COMMAND-NOTFOUND")
|
||||
message(WARNING "Valgrind couldn't be found.")
|
||||
diff --git a/tests/misc_tests.c b/tests/misc_tests.c
|
||||
index ba3e003e..94dd91aa 100644
|
||||
--- a/tests/misc_tests.c
|
||||
+++ b/tests/misc_tests.c
|
||||
@@ -732,6 +732,23 @@ static void cjson_set_bool_value_must_not_break_objects(void)
|
||||
cJSON_Delete(sobj);
|
||||
}
|
||||
|
||||
+static void deallocated_pointers_should_be_set_to_null(void)
|
||||
+{
|
||||
+ /* deallocated pointers should be set to null */
|
||||
+ /* however, valgrind on linux reports when attempting to access a freed memory, we have to skip it */
|
||||
+#ifndef ENABLE_VALGRIND
|
||||
+ cJSON *string = cJSON_CreateString("item");
|
||||
+ cJSON *root = cJSON_CreateObject();
|
||||
+
|
||||
+ cJSON_Delete(string);
|
||||
+ free(string->valuestring);
|
||||
+
|
||||
+ cJSON_AddObjectToObject(root, "object");
|
||||
+ cJSON_Delete(root->child);
|
||||
+ free(root->child->string);
|
||||
+#endif
|
||||
+}
|
||||
+
|
||||
int CJSON_CDECL main(void)
|
||||
{
|
||||
UNITY_BEGIN();
|
||||
@@ -762,6 +779,7 @@ int CJSON_CDECL main(void)
|
||||
RUN_TEST(cjson_delete_item_from_array_should_not_broken_list_structure);
|
||||
RUN_TEST(cjson_set_valuestring_to_object_should_not_leak_memory);
|
||||
RUN_TEST(cjson_set_bool_value_must_not_break_objects);
|
||||
+ RUN_TEST(deallocated_pointers_should_be_set_to_null);
|
||||
|
||||
return UNITY_END();
|
||||
}
|
BIN
cJSON-1.7.18.tar.gz
(Stored with Git LFS)
Normal file
BIN
cJSON-1.7.18.tar.gz
(Stored with Git LFS)
Normal file
Binary file not shown.
15
cJSON-fix-cmake-include-path.patch
Normal file
15
cJSON-fix-cmake-include-path.patch
Normal file
@ -0,0 +1,15 @@
|
||||
diff --git a/library_config/cJSONConfig.cmake.in b/library_config/cJSONConfig.cmake.in
|
||||
index 909f7a9..0c99643 100644
|
||||
--- a/library_config/cJSONConfig.cmake.in
|
||||
+++ b/library_config/cJSONConfig.cmake.in
|
||||
@@ -2,8 +2,8 @@
|
||||
set(CJSON_UTILS_FOUND @ENABLE_CJSON_UTILS@)
|
||||
|
||||
# The include directories used by cJSON
|
||||
-set(CJSON_INCLUDE_DIRS "@CMAKE_INSTALL_FULL_INCLUDEDIR@")
|
||||
-set(CJSON_INCLUDE_DIR "@CMAKE_INSTALL_FULL_INCLUDEDIR@")
|
||||
+set(CJSON_INCLUDE_DIRS "@CMAKE_INSTALL_FULL_INCLUDEDIR@/cjson")
|
||||
+set(CJSON_INCLUDE_DIR "@CMAKE_INSTALL_FULL_INCLUDEDIR@/cjson")
|
||||
|
||||
get_filename_component(_dir "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
||||
|
70
cJSON.changes
Normal file
70
cJSON.changes
Normal file
@ -0,0 +1,70 @@
|
||||
-------------------------------------------------------------------
|
||||
Wed Jun 5 16:34:08 UTC 2024 - Dirk Müller <dmueller@suse.com>
|
||||
|
||||
- unconditionally apply the revert NULL pointer test
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu May 23 18:03:45 UTC 2024 - Andreas Stieger <andreas.stieger@gmx.de>
|
||||
|
||||
- update to 1.7.18:
|
||||
* CVE-2024-31755: NULL pointer dereference via
|
||||
cJSON_SetValuestring() (boo#1223420)
|
||||
* Remove non-functional list handling of compiler flags
|
||||
* Fix heap buffer overflow
|
||||
* remove misused optimization flag -01
|
||||
* Set free'd pointers to NULL whenever they are not reassigned
|
||||
immediately after
|
||||
- revert tests for NULL pointers that fail on Leap 15.5
|
||||
cJSON-1.7.18-misc_tests.patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Mon Feb 26 10:45:07 UTC 2024 - Dominique Leuenberger <dimstar@opensuse.org>
|
||||
|
||||
- Use %autosetup macro. Allows to eliminate the usage of deprecated
|
||||
PatchN.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Dec 26 09:29:11 UTC 2023 - Martin Hauke <mardnh@gmx.de>
|
||||
|
||||
- Update to version 1.7.17 (bsc#1218098, CVE-2023-50472,
|
||||
bsc#1218099, CVE-2023-50471):
|
||||
* Fix null reference in cJSON_SetValuestring (CVE-2023-50472).
|
||||
* Fix null reference in cJSON_InsertItemInArray (CVE-2023-50471).
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Sun Jul 16 19:13:10 UTC 2023 - Dirk Müller <dmueller@suse.com>
|
||||
|
||||
- update to 1.7.16:
|
||||
* Add an option for ENABLE_CJSON_VERSION_SO in CMakeLists.txt
|
||||
* Add cmake_policy to CMakeLists.txt
|
||||
* Add cJSON_SetBoolValue
|
||||
* Add meson documentation
|
||||
* Fix memory leak in merge_patch
|
||||
* Fix conflicting target names 'uninstall'
|
||||
* Bump cmake version to 3.0 and use new version syntax
|
||||
* Print int without decimal places
|
||||
* Fix 'cjson_utils-static' target not exist
|
||||
* Add allocate check for replace_item_in_object
|
||||
* Fix a null pointer crash in cJSON_ReplaceItemViaPointer
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Aug 25 11:45:18 UTC 2021 - Martin Hauke <mardnh@gmx.de>
|
||||
|
||||
- Update to version 1.7.15
|
||||
* Fix potential core dumped for strrchr.
|
||||
* Fix null pointer crash in cJSON_CreateXxArray.
|
||||
* Fix several null pointer problems on allocation failure.
|
||||
* Fix a possible dereference of null pointer.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Mon Dec 28 09:52:51 UTC 2020 - Martin Hauke <mardnh@gmx.de>
|
||||
|
||||
- Set proper library path via LD_LIBRARY_PATH for ctest
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Sat Dec 5 12:44:22 UTC 2020 - Martin Hauke <mardnh@gmx.de>
|
||||
|
||||
- Initial package, version 1.7.14
|
||||
- Add patch:
|
||||
* cJSON-fix-cmake-include-path.patch
|
||||
Align CMake include path with the one provided by pkg-config
|
90
cJSON.spec
Normal file
90
cJSON.spec
Normal file
@ -0,0 +1,90 @@
|
||||
#
|
||||
# spec file for package cJSON
|
||||
#
|
||||
# Copyright (c) 2024 SUSE LLC
|
||||
# Copyright (c) 2020-2023, Martin Hauke <mardnh@gmx.de>
|
||||
# Copyright (c) 2024 Andreas Stieger <Andreas.Stieger@gmx.de>
|
||||
#
|
||||
# All modifications and additions to the file contributed by third parties
|
||||
# remain the property of their copyright owners, unless otherwise agreed
|
||||
# upon. The license for this file, and modifications and additions to the
|
||||
# file, is the same license as for the pristine package itself (unless the
|
||||
# license for the pristine package is not an Open Source License, in which
|
||||
# case the license is the MIT License). An "Open Source License" is a
|
||||
# license that conforms to the Open Source Definition (Version 1.9)
|
||||
# published by the Open Source Initiative.
|
||||
|
||||
# Please submit bugfixes or comments via https://bugs.opensuse.org/
|
||||
#
|
||||
|
||||
|
||||
%global sover 1
|
||||
%global libname libcjson%{sover}
|
||||
Name: cJSON
|
||||
Version: 1.7.18
|
||||
Release: 0
|
||||
Summary: JSON parser library written in ANSI C
|
||||
License: MIT
|
||||
Group: System/Libraries
|
||||
URL: https://github.com/DaveGamble/cJSON
|
||||
Source: https://github.com/DaveGamble/cJSON/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
|
||||
Patch0: cJSON-fix-cmake-include-path.patch
|
||||
Patch1: cJSON-1.7.18-misc_tests.patch
|
||||
BuildRequires: cmake
|
||||
BuildRequires: pkgconfig
|
||||
|
||||
%description
|
||||
A simple JSON parser library written in ANSI C.
|
||||
|
||||
%package -n %{libname}
|
||||
Summary: JSON parser library written in ANSI C
|
||||
Group: System/Libraries
|
||||
|
||||
%description -n %{libname}
|
||||
A simple JSON parser library written in ANSI C.
|
||||
|
||||
%package devel
|
||||
Summary: Development files for the cJSON library
|
||||
Group: Development/Libraries/C and C++
|
||||
Requires: %{libname} = %{version}
|
||||
|
||||
%description devel
|
||||
A simple JSON parser library written in ANSI C.
|
||||
|
||||
This subpackage contains libraries and header files for developing
|
||||
applications that want to make use of libcjson.
|
||||
|
||||
%prep
|
||||
%setup -q
|
||||
# test is doing an access of freed memory which is undefined and glibc
|
||||
# is poisioning our memory so it's failing
|
||||
%patch -P1 -p1 -R
|
||||
|
||||
%build
|
||||
%cmake
|
||||
%cmake_build
|
||||
|
||||
%install
|
||||
%cmake_install
|
||||
|
||||
%ldconfig_scriptlets -n %{libname}
|
||||
|
||||
%check
|
||||
export LD_LIBRARY_PATH=%{buildroot}%{_libdir}
|
||||
%ctest
|
||||
|
||||
%files -n %{libname}
|
||||
%license LICENSE
|
||||
%doc CHANGELOG.md CONTRIBUTORS.md README.md
|
||||
%{_libdir}/libcjson.so.%{sover}*
|
||||
|
||||
%files devel
|
||||
%license LICENSE
|
||||
%dir %{_includedir}/cjson
|
||||
%{_includedir}/cjson/cJSON.h
|
||||
%dir %{_libdir}/cmake/cJSON
|
||||
%{_libdir}/cmake/cJSON/*.cmake
|
||||
%{_libdir}/libcjson.so
|
||||
%{_libdir}/pkgconfig/libcjson.pc
|
||||
|
||||
%changelog
|
Loading…
Reference in New Issue
Block a user