From 20e7c751f6e1d00f9bfe9e97a37bae76654dfeca Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Nov 02 2019 21:22:23 +0000 Subject: import libfastjson-0.99.4-3.el7 --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9aecf32 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +SOURCES/libfastjson-0.99.4.tar.gz diff --git a/.libfastjson.metadata b/.libfastjson.metadata new file mode 100644 index 0000000..d582aae --- /dev/null +++ b/.libfastjson.metadata @@ -0,0 +1 @@ +f8f11a0635c87abde03367fbb4fe13bf3fdb514e SOURCES/libfastjson-0.99.4.tar.gz diff --git a/SOURCES/0001-Bug-1591493-add-support-for-array-item-deletion.patch b/SOURCES/0001-Bug-1591493-add-support-for-array-item-deletion.patch new file mode 100644 index 0000000..127fae8 --- /dev/null +++ b/SOURCES/0001-Bug-1591493-add-support-for-array-item-deletion.patch @@ -0,0 +1,100 @@ +From 51cf76acb55aa933212c9ac78176835e1b12c7e6 Mon Sep 17 00:00:00 2001 +From: Noriko Hosoi +Date: Fri, 25 May 2018 11:09:46 -0700 +Subject: [PATCH] Bug 1591493 - add support for array item deletion + +Adding "void fjson_object_array_del_idx(struct fjson_object *jso, int idx)", +which deletes the idx-th element in the array type object. + +(cherry picked from commit e32df78fc68a4ae881681b5f845967edd6b86004 -- https://github.com/rsyslog/libfastjson) +--- + arraylist.c | 16 ++++++++++++++++ + arraylist.h | 3 +++ + json_object.c | 8 ++++++++ + json_object.h | 3 +++ + 4 files changed, 30 insertions(+) + +diff --git a/arraylist.c b/arraylist.c +index 210b5c5..fc8dfe1 100644 +--- a/arraylist.c ++++ b/arraylist.c +@@ -87,6 +87,22 @@ array_list_add(struct array_list *arr, void *data) + return array_list_put_idx(arr, arr->length, data); + } + ++/* ++ * Deleting the idx-th element in the array_list. ++ */ ++void ++array_list_del_idx(struct array_list *const arr, const int idx) ++{ ++ if (idx < 0 || idx >= arr->length) { ++ return; ++ } ++ if(arr->array[idx]) arr->free_fn(arr->array[idx]); ++ if (--arr->length > idx) { ++ memmove(arr->array + idx, arr->array + idx + 1, (arr->length - idx) * sizeof(void *)); ++ } ++ return; ++} ++ + /* work around wrong compiler message: GCC and clang do + * not handle sort_fn correctly if -Werror is given. + */ +diff --git a/arraylist.h b/arraylist.h +index 4b0f9e8..54ddad4 100644 +--- a/arraylist.h ++++ b/arraylist.h +@@ -41,6 +41,9 @@ array_list_put_idx(struct array_list *al, int i, void *data); + extern int + array_list_add(struct array_list *al, void *data); + ++extern void ++array_list_del_idx(struct array_list *const arr, const int idx); ++ + extern int + array_list_length(struct array_list *al); + +diff --git a/json_object.c b/json_object.c +index 56e8df6..42e516f 100644 +--- a/json_object.c ++++ b/json_object.c +@@ -1053,6 +1053,14 @@ struct fjson_object* fjson_object_array_get_idx(struct fjson_object *jso, + return (struct fjson_object*)array_list_get_idx(jso->o.c_array, idx); + } + ++/* ++ * Deleting the idx-th element in the array type object. ++ */ ++void fjson_object_array_del_idx(struct fjson_object *jso, int idx) ++{ ++ array_list_del_idx(jso->o.c_array, idx); ++} ++ + int fjson_object_get_member_count(struct fjson_object *jso) + { + return jso->o.c_obj.nelem; +diff --git a/json_object.h b/json_object.h +index 55ee177..80a2075 100644 +--- a/json_object.h ++++ b/json_object.h +@@ -469,6 +469,8 @@ extern int fjson_object_array_put_idx(struct fjson_object *obj, int idx, + extern struct fjson_object* fjson_object_array_get_idx(struct fjson_object *obj, + int idx); + ++extern void fjson_object_array_del_idx(struct fjson_object *jso, int idx); ++ + /* fjson_bool type methods */ + + /** Create a new empty fjson_object of type fjson_type_boolean +@@ -720,6 +722,7 @@ typedef struct fjson_tokener fjson_tokener; + #define json_object_get_int64 fjson_object_get_int64 + #define json_object_get_string_len fjson_object_get_string_len + #define json_object_get_member_count fjson_object_get_member_count ++#define json_object_array_del_idx fjson_object_array_del_idx + + + #endif +-- +2.14.4 + diff --git a/SOURCES/libfastjson-0.99.4-rhbz1421612-nullptr-guard.patch b/SOURCES/libfastjson-0.99.4-rhbz1421612-nullptr-guard.patch new file mode 100644 index 0000000..9c9b967 --- /dev/null +++ b/SOURCES/libfastjson-0.99.4-rhbz1421612-nullptr-guard.patch @@ -0,0 +1,28 @@ +From 8793b9a1bda1d6e182a1118a6f1a0688f530a545 Mon Sep 17 00:00:00 2001 +From: Jiri Vymazal +Date: Thu, 2 Mar 2017 12:35:37 +0100 +Subject: [PATCH] add nullptr guard + +--- + json_object.c | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +diff --git a/json_object.c b/json_object.c +index b01782e..f8fc41b 100644 +--- a/json_object.c ++++ b/json_object.c +@@ -201,9 +201,11 @@ int fjson_object_put(struct fjson_object *jso) + + static void fjson_object_generic_delete(struct fjson_object* jso) + { +- printbuf_free(jso->_pb); +- DESTROY_ATOMIC_HELPER_MUT(jso->_mut_ref_count); +- free(jso); ++ if (jso) { ++ printbuf_free(jso->_pb); ++ DESTROY_ATOMIC_HELPER_MUT(jso->_mut_ref_count); ++ free(jso); ++ } + } + + static struct fjson_object* fjson_object_new(const enum fjson_type o_type) diff --git a/SPECS/libfastjson.spec b/SPECS/libfastjson.spec new file mode 100644 index 0000000..a29bdad --- /dev/null +++ b/SPECS/libfastjson.spec @@ -0,0 +1,76 @@ +Name: libfastjson +Version: 0.99.4 +Release: 3%{?dist} +Summary: A JSON implementation in C +License: MIT +URL: https://github.com/rsyslog/libfastjson +Source0: http://download.rsyslog.com/libfastjson/libfastjson-%{version}.tar.gz + +# 1421612 - New defect found in libfastjson-0.99.4-1.el7 +Patch0: libfastjson-0.99.4-rhbz1421612-nullptr-guard.patch +Patch1: 0001-Bug-1591493-add-support-for-array-item-deletion.patch + +%description +LIBFASTJSON implements a reference counting object +model that allows you to easily construct JSON +objects in C, output them as JSON formatted strings +and parse JSON formatted strings back into the +C representation of JSON objects. + +%package devel +Summary: Development files for libfastjson +Group: Development/Libraries +Requires: %{name}%{?_isa} = %{version}-%{release} + +%description devel +This package contains libraries and header files for +developing applications that use libfastjson. + +%prep +%setup -q +%patch0 -p1 +%patch1 -p1 + +for doc in ChangeLog; do + iconv -f iso-8859-1 -t utf8 $doc > $doc.new && + touch -r $doc $doc.new && + mv $doc.new $doc +done + +%build +export CFLAGS="$RPM_OPT_FLAGS -D_GNU_SOURCE" # temporary workaround for EPEL5, fixed upstream +%configure --enable-shared --disable-static + +%install +make V=1 DESTDIR=%{buildroot} install +find %{buildroot} -name '*.la' -delete -print + +%check +make V=1 check + +%post -p /sbin/ldconfig + +%postun -p /sbin/ldconfig + +%files +%{!?_licensedir:%global license %%doc} +%license COPYING +%doc AUTHORS ChangeLog README.html +%{_libdir}/libfastjson.so.* + +%files devel +%{_includedir}/libfastjson +%{_libdir}/libfastjson.so +%{_libdir}/pkgconfig/libfastjson.pc + +%changelog +* Fri Jun 22 2018 Noriko Hosoi - 0.99.4-3 + Resolves: #1591493 - add support for array item deletion + +* Tue Mar 07 2017 Daniel Kopecek - 0.99.4-2 +- Fix defect found by clang-analyzer + Resolves: #1421612 + +* Tue Jan 24 2017 Daniel Kopecek - 0.99.4-1 +- Import + Resolves: #1395145