Update to 0.15

Changes:	https://github.com/json-c/json-c/blob/master/ChangeLog
PR:		248340
Submitted by:	Daniel Engberg <daniel.engberg.lists@pyret.net>
Exp-run by:	antoine
This commit is contained in:
Sunpoet Po-Chuan Hsieh 2020-08-15 17:12:03 +00:00
parent 4de83eb2c3
commit e518f42a23
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=545049
8 changed files with 5 additions and 175 deletions

View File

@ -2,7 +2,7 @@
# $FreeBSD$
PORTNAME= json-c
PORTVERSION= 0.14
PORTVERSION= 0.15
CATEGORIES= devel
MASTER_SITES= https://s3.amazonaws.com/json-c_releases/releases/ \
LOCAL/sunpoet

View File

@ -1,3 +1,3 @@
TIMESTAMP = 1588350160
SHA256 (json-c-0.14.tar.gz) = b377de08c9b23ca3b37d9a9828107dff1de5ce208ff4ebb35005a794f30c6870
SIZE (json-c-0.14.tar.gz) = 321677
TIMESTAMP = 1597081472
SHA256 (json-c-0.15.tar.gz) = b8d80a1ddb718b3ba7492916237bbf86609e9709fb007e7f7d4322f02341a4c6
SIZE (json-c-0.15.tar.gz) = 361488

View File

@ -1,56 +0,0 @@
Obtained from: https://github.com/json-c/json-c/commit/8b511c402b73d1d8b195991891c8d44859cb57ec
https://github.com/json-c/json-c/commit/22870ac2bd4cfdd135887ecc8cbbe02e7ef0c34e
https://github.com/json-c/json-c/commit/4f43a077a497f94214645ce9763247ec085e2094
--- CMakeLists.txt.orig 2020-04-19 03:39:09 UTC
+++ CMakeLists.txt
@@ -65,6 +65,7 @@ include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
option(BUILD_SHARED_LIBS "Default to building shared libraries" ON)
+option(BUILD_STATIC_LIBS "Default to building static libraries" ON)
# Generate a release merge and test it to verify the correctness of republishing the package.
ADD_CUSTOM_TARGET(distcheck
@@ -299,7 +300,7 @@ if ($ENV{VALGRIND})
endif()
set(JSON_C_PUBLIC_HEADERS
- ${PROJECT_BINARY_DIR}/config.h
+ # Note: config.h is _not_ included here
${PROJECT_BINARY_DIR}/json_config.h
${PROJECT_SOURCE_DIR}/json.h
@@ -383,7 +384,7 @@ add_library(${PROJECT_NAME}
set_target_properties(${PROJECT_NAME} PROPERTIES
VERSION 5.0.0
SOVERSION 5)
-
+list(APPEND CMAKE_TARGETS ${PROJECT_NAME})
# If json-c is used as subroject it set to target correct interface -I flags and allow
# to build external target without extra include_directories(...)
target_include_directories(${PROJECT_NAME}
@@ -392,7 +393,22 @@ target_include_directories(${PROJECT_NAME}
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
)
-install(TARGETS ${PROJECT_NAME}
+# Allow to build static and shared libraries at the same time
+if (BUILD_STATIC_LIBS AND BUILD_SHARED_LIBS)
+ set(STATIC_LIB ${PROJECT_NAME}-static)
+ add_library(${STATIC_LIB} STATIC
+ ${JSON_C_SOURCES}
+ ${JSON_C_HEADERS}
+ )
+
+ # rename the static library
+ set_target_properties(${STATIC_LIB} PROPERTIES
+ OUTPUT_NAME ${PROJECT_NAME}
+ )
+ list(APPEND CMAKE_TARGETS ${STATIC_LIB})
+endif ()
+
+install(TARGETS ${CMAKE_TARGETS}
EXPORT ${PROJECT_NAME}-targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}

View File

@ -1,14 +0,0 @@
Obtained from: https://github.com/json-c/json-c/commit/31243e4d1204ef78be34b0fcae73221eee6b83be
--- arraylist.c.orig 2020-04-19 03:36:00 UTC
+++ arraylist.c
@@ -136,6 +136,9 @@ int array_list_del_idx(struct array_list *arr, size_t
{
size_t i, stop;
+ /* Avoid overflow in calculation with large indices. */
+ if (idx > SIZE_T_MAX - count)
+ return -1;
stop = idx + count;
if (idx >= arr->length || stop > arr->length)
return -1;

View File

@ -1,11 +0,0 @@
--- json_object.c.orig 2020-04-19 03:36:00 UTC
+++ json_object.c
@@ -735,7 +735,7 @@ int64_t json_object_get_int64(const struct json_object
// so cast to tell the compiler it's ok to round up.
if (jso->o.c_double >= (double)INT64_MAX)
return INT64_MAX;
- if (jso->o.c_double <= INT64_MIN)
+ if (jso->o.c_double <= (double)INT64_MIN)
return INT64_MIN;
return (int64_t)jso->o.c_double;
case json_type_boolean: return jso->o.c_boolean;

View File

@ -1,37 +0,0 @@
Obtained from: https://github.com/json-c/json-c/commit/31243e4d1204ef78be34b0fcae73221eee6b83be
https://github.com/json-c/json-c/commit/519dfe1591d85432986f9762d41d1a883198c157
--- linkhash.c.orig 2020-04-19 03:36:00 UTC
+++ linkhash.c
@@ -12,6 +12,7 @@
#include "config.h"
+#include <assert.h>
#include <limits.h>
#include <stdarg.h>
#include <stddef.h>
@@ -499,6 +500,8 @@ struct lh_table *lh_table_new(int size, lh_entry_free_
int i;
struct lh_table *t;
+ /* Allocate space for elements to avoid divisions by zero. */
+ assert(size > 0);
t = (struct lh_table *)calloc(1, sizeof(struct lh_table));
if (!t)
return NULL;
@@ -577,9 +580,12 @@ int lh_table_insert_w_hash(struct lh_table *t, const v
{
unsigned long n;
- if (t->count >= t->size * LH_LOAD_FACTOR)
- if (lh_table_resize(t, t->size * 2) != 0)
+ if (t->count >= t->size * LH_LOAD_FACTOR) {
+ /* Avoid signed integer overflow with large tables. */
+ int new_size = (t->size > INT_MAX / 2) ? INT_MAX : (t->size * 2);
+ if (t->size == INT_MAX || lh_table_resize(t, new_size) != 0)
return -1;
+ }
n = h % t->size;

View File

@ -1,52 +0,0 @@
Obtained from: https://github.com/json-c/json-c/commit/31243e4d1204ef78be34b0fcae73221eee6b83be
--- printbuf.c.orig 2020-04-19 03:36:00 UTC
+++ printbuf.c
@@ -15,6 +15,7 @@
#include "config.h"
+#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -65,10 +66,16 @@ static int printbuf_extend(struct printbuf *p, int min
if (p->size >= min_size)
return 0;
-
- new_size = p->size * 2;
- if (new_size < min_size + 8)
+ /* Prevent signed integer overflows with large buffers. */
+ if (min_size > INT_MAX - 8)
+ return -1;
+ if (p->size > INT_MAX / 2)
new_size = min_size + 8;
+ else {
+ new_size = p->size * 2;
+ if (new_size < min_size + 8)
+ new_size = min_size + 8;
+ }
#ifdef PRINTBUF_DEBUG
MC_DEBUG("printbuf_memappend: realloc "
"bpos=%d min_size=%d old_size=%d new_size=%d\n",
@@ -83,6 +90,9 @@ static int printbuf_extend(struct printbuf *p, int min
int printbuf_memappend(struct printbuf *p, const char *buf, int size)
{
+ /* Prevent signed integer overflows with large buffers. */
+ if (size > INT_MAX - p->bpos - 1)
+ return -1;
if (p->size <= p->bpos + size + 1)
{
if (printbuf_extend(p, p->bpos + size + 1) < 0)
@@ -100,6 +110,9 @@ int printbuf_memset(struct printbuf *pb, int offset, i
if (offset == -1)
offset = pb->bpos;
+ /* Prevent signed integer overflows with large buffers. */
+ if (len > INT_MAX - offset)
+ return -1;
size_needed = offset + len;
if (pb->size < size_needed)
{

View File

@ -20,5 +20,5 @@ lib/cmake/json-c/json-c-targets.cmake
lib/libjson-c.a
lib/libjson-c.so
lib/libjson-c.so.5
lib/libjson-c.so.5.0.0
lib/libjson-c.so.5.1.0
libdata/pkgconfig/json-c.pc