View | Details | Raw Unified | Return to bug 248340
Collapse All | Expand All

(-)b/devel/json-c/Makefile (-1 / +1 lines)
Lines 2-8 Link Here
2
# $FreeBSD$
2
# $FreeBSD$
3
3
4
PORTNAME=	json-c
4
PORTNAME=	json-c
5
PORTVERSION=	0.14
5
PORTVERSION=	0.15
6
CATEGORIES=	devel
6
CATEGORIES=	devel
7
MASTER_SITES=	https://s3.amazonaws.com/json-c_releases/releases/ \
7
MASTER_SITES=	https://s3.amazonaws.com/json-c_releases/releases/ \
8
		LOCAL/sunpoet
8
		LOCAL/sunpoet
(-)b/devel/json-c/distinfo (-3 / +3 lines)
Lines 1-3 Link Here
1
TIMESTAMP = 1588350160
1
TIMESTAMP = 1596001230
2
SHA256 (json-c-0.14.tar.gz) = b377de08c9b23ca3b37d9a9828107dff1de5ce208ff4ebb35005a794f30c6870
2
SHA256 (json-c-0.15.tar.gz) = b8d80a1ddb718b3ba7492916237bbf86609e9709fb007e7f7d4322f02341a4c6
3
SIZE (json-c-0.14.tar.gz) = 321677
3
SIZE (json-c-0.15.tar.gz) = 361488
(-)a/devel/json-c/files/patch-CMakeLists.txt (-56 lines)
Removed Link Here
1
Obtained from:	https://github.com/json-c/json-c/commit/8b511c402b73d1d8b195991891c8d44859cb57ec
2
		https://github.com/json-c/json-c/commit/22870ac2bd4cfdd135887ecc8cbbe02e7ef0c34e
3
		https://github.com/json-c/json-c/commit/4f43a077a497f94214645ce9763247ec085e2094
4
5
--- CMakeLists.txt.orig	2020-04-19 03:39:09 UTC
6
+++ CMakeLists.txt
7
@@ -65,6 +65,7 @@ include(GNUInstallDirs)
8
 include(CMakePackageConfigHelpers)
9
 
10
 option(BUILD_SHARED_LIBS  "Default to building shared libraries" ON)
11
+option(BUILD_STATIC_LIBS  "Default to building static libraries" ON)
12
 
13
 # Generate a release merge and test it to verify the correctness of republishing the package.
14
 ADD_CUSTOM_TARGET(distcheck
15
@@ -299,7 +300,7 @@ if ($ENV{VALGRIND})
16
 endif()
17
 
18
 set(JSON_C_PUBLIC_HEADERS
19
-    ${PROJECT_BINARY_DIR}/config.h
20
+    # Note: config.h is _not_ included here
21
     ${PROJECT_BINARY_DIR}/json_config.h
22
 
23
     ${PROJECT_SOURCE_DIR}/json.h
24
@@ -383,7 +384,7 @@ add_library(${PROJECT_NAME}
25
 set_target_properties(${PROJECT_NAME} PROPERTIES
26
     VERSION 5.0.0
27
     SOVERSION 5)
28
-
29
+list(APPEND CMAKE_TARGETS ${PROJECT_NAME})
30
 # If json-c is used as subroject it set to target correct interface -I flags and allow
31
 # to build external target without extra include_directories(...)
32
 target_include_directories(${PROJECT_NAME}
33
@@ -392,7 +393,22 @@ target_include_directories(${PROJECT_NAME}
34
         $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
35
 )
36
 
37
-install(TARGETS ${PROJECT_NAME}
38
+# Allow to build static and shared libraries at the same time
39
+if (BUILD_STATIC_LIBS AND BUILD_SHARED_LIBS)
40
+    set(STATIC_LIB ${PROJECT_NAME}-static)
41
+    add_library(${STATIC_LIB} STATIC
42
+        ${JSON_C_SOURCES}
43
+        ${JSON_C_HEADERS}
44
+    )
45
+
46
+    # rename the static library
47
+    set_target_properties(${STATIC_LIB} PROPERTIES
48
+        OUTPUT_NAME ${PROJECT_NAME}
49
+    )
50
+    list(APPEND CMAKE_TARGETS ${STATIC_LIB})
51
+endif ()
52
+
53
+install(TARGETS ${CMAKE_TARGETS}
54
     EXPORT ${PROJECT_NAME}-targets
55
     RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
56
     LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
(-)a/devel/json-c/files/patch-arraylist.c (-14 lines)
Removed Link Here
1
Obtained from:	https://github.com/json-c/json-c/commit/31243e4d1204ef78be34b0fcae73221eee6b83be
2
3
--- arraylist.c.orig	2020-04-19 03:36:00 UTC
4
+++ arraylist.c
5
@@ -136,6 +136,9 @@ int array_list_del_idx(struct array_list *arr, size_t 
6
 {
7
 	size_t i, stop;
8
 
9
+	/* Avoid overflow in calculation with large indices. */
10
+	if (idx > SIZE_T_MAX - count)
11
+		return -1;
12
 	stop = idx + count;
13
 	if (idx >= arr->length || stop > arr->length)
14
 		return -1;
(-)a/devel/json-c/files/patch-json_object.c (-11 lines)
Removed Link Here
1
--- json_object.c.orig	2020-04-19 03:36:00 UTC
2
+++ json_object.c
3
@@ -735,7 +735,7 @@ int64_t json_object_get_int64(const struct json_object
4
 		// so cast to tell the compiler it's ok to round up.
5
 		if (jso->o.c_double >= (double)INT64_MAX)
6
 			return INT64_MAX;
7
-		if (jso->o.c_double <= INT64_MIN)
8
+		if (jso->o.c_double <= (double)INT64_MIN)
9
 			return INT64_MIN;
10
 		return (int64_t)jso->o.c_double;
11
 	case json_type_boolean: return jso->o.c_boolean;
(-)a/devel/json-c/files/patch-linkhash.c (-37 lines)
Removed Link Here
1
Obtained from:	https://github.com/json-c/json-c/commit/31243e4d1204ef78be34b0fcae73221eee6b83be
2
		https://github.com/json-c/json-c/commit/519dfe1591d85432986f9762d41d1a883198c157
3
4
--- linkhash.c.orig	2020-04-19 03:36:00 UTC
5
+++ linkhash.c
6
@@ -12,6 +12,7 @@
7
 
8
 #include "config.h"
9
 
10
+#include <assert.h>
11
 #include <limits.h>
12
 #include <stdarg.h>
13
 #include <stddef.h>
14
@@ -499,6 +500,8 @@ struct lh_table *lh_table_new(int size, lh_entry_free_
15
 	int i;
16
 	struct lh_table *t;
17
 
18
+	/* Allocate space for elements to avoid divisions by zero. */
19
+	assert(size > 0);
20
 	t = (struct lh_table *)calloc(1, sizeof(struct lh_table));
21
 	if (!t)
22
 		return NULL;
23
@@ -577,9 +580,12 @@ int lh_table_insert_w_hash(struct lh_table *t, const v
24
 {
25
 	unsigned long n;
26
 
27
-	if (t->count >= t->size * LH_LOAD_FACTOR)
28
-		if (lh_table_resize(t, t->size * 2) != 0)
29
+	if (t->count >= t->size * LH_LOAD_FACTOR) {
30
+		/* Avoid signed integer overflow with large tables. */
31
+		int new_size = (t->size > INT_MAX / 2) ? INT_MAX : (t->size * 2);
32
+		if (t->size == INT_MAX || lh_table_resize(t, new_size) != 0)
33
 			return -1;
34
+	}
35
 
36
 	n = h % t->size;
37
 
(-)a/devel/json-c/files/patch-printbuf.c (-52 lines)
Removed Link Here
1
Obtained from:	https://github.com/json-c/json-c/commit/31243e4d1204ef78be34b0fcae73221eee6b83be
2
3
--- printbuf.c.orig	2020-04-19 03:36:00 UTC
4
+++ printbuf.c
5
@@ -15,6 +15,7 @@
6
 
7
 #include "config.h"
8
 
9
+#include <limits.h>
10
 #include <stdio.h>
11
 #include <stdlib.h>
12
 #include <string.h>
13
@@ -65,10 +66,16 @@ static int printbuf_extend(struct printbuf *p, int min
14
 
15
 	if (p->size >= min_size)
16
 		return 0;
17
-
18
-	new_size = p->size * 2;
19
-	if (new_size < min_size + 8)
20
+	/* Prevent signed integer overflows with large buffers. */
21
+	if (min_size > INT_MAX - 8)
22
+		return -1;
23
+	if (p->size > INT_MAX / 2)
24
 		new_size = min_size + 8;
25
+	else {
26
+		new_size = p->size * 2;
27
+		if (new_size < min_size + 8)
28
+			new_size = min_size + 8;
29
+	}
30
 #ifdef PRINTBUF_DEBUG
31
 	MC_DEBUG("printbuf_memappend: realloc "
32
 	         "bpos=%d min_size=%d old_size=%d new_size=%d\n",
33
@@ -83,6 +90,9 @@ static int printbuf_extend(struct printbuf *p, int min
34
 
35
 int printbuf_memappend(struct printbuf *p, const char *buf, int size)
36
 {
37
+	/* Prevent signed integer overflows with large buffers. */
38
+	if (size > INT_MAX - p->bpos - 1)
39
+		return -1;
40
 	if (p->size <= p->bpos + size + 1)
41
 	{
42
 		if (printbuf_extend(p, p->bpos + size + 1) < 0)
43
@@ -100,6 +110,9 @@ int printbuf_memset(struct printbuf *pb, int offset, i
44
 
45
 	if (offset == -1)
46
 		offset = pb->bpos;
47
+	/* Prevent signed integer overflows with large buffers. */
48
+	if (len > INT_MAX - offset)
49
+		return -1;
50
 	size_needed = offset + len;
51
 	if (pb->size < size_needed)
52
 	{
(-)b/devel/json-c/pkg-plist (-1 / +1 lines)
Lines 20-24 lib/cmake/json-c/json-c-targets.cmake Link Here
20
lib/libjson-c.a
20
lib/libjson-c.a
21
lib/libjson-c.so
21
lib/libjson-c.so
22
lib/libjson-c.so.5
22
lib/libjson-c.so.5
23
lib/libjson-c.so.5.0.0
23
lib/libjson-c.so.5.1.0
24
libdata/pkgconfig/json-c.pc
24
libdata/pkgconfig/json-c.pc

Return to bug 248340