Skip to content

Commit 4cfbaa7

Browse files
Update json-c from 0.15 to 0.16 (#2600)
1 parent 01274bf commit 4cfbaa7

22 files changed

+525
-246
lines changed

vendor/json-c/ChangeLog

Lines changed: 60 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,60 @@
11

2-
Next Release 0.15
3-
=====================
2+
0.16 (up to commit 66dcdf5, 2022-04-13)
3+
========================================
4+
5+
Deprecated and removed features:
6+
--------------------------------
7+
* JSON_C_OBJECT_KEY_IS_CONSTANT is deprecated in favor of
8+
JSON_C_OBJECT_ADD_CONSTANT_KEY
9+
* Direct access to lh_table and lh_entry structure members is deprecated.
10+
Use access functions instead, lh_table_head(), lh_entry_next(), etc...
11+
* Drop REFCOUNT_DEBUG code.
12+
13+
New features
14+
------------
15+
* The 0.16 release introduces no new features
16+
17+
Build changes
18+
-------------
19+
* Add a DISABLE_EXTRA_LIBS option to skip using libbsd
20+
* Add a DISABLE_JSON_POINTER option to skip compiling in json_pointer support.
21+
22+
Significant changes and bug fixes
23+
---------------------------------
24+
* Cap string length at INT_MAX to avoid various issues with very long strings.
25+
* json_object_deep_copy: fix deep copy of strings containing '\0'
26+
* Fix read past end of buffer in the "json_parse" command
27+
* Avoid out of memory accesses in the locally provided vasprintf() function
28+
(for those platforms that use it)
29+
* Handle allocation failure in json_tokener_new_ex
30+
* Fix use-after-free in json_tokener_new_ex() in the event of printbuf_new() returning NULL
31+
* printbuf_memset(): set gaps to zero - areas within the print buffer which
32+
have not been initialized by using printbuf_memset
33+
* printbuf: return -1 on invalid arguments (len < 0 or total buffer > INT_MAX)
34+
* sprintbuf(): propagate printbuf_memappend errors back to the caller
35+
36+
Optimizations
37+
--------------
38+
* Speed up parsing by replacing ctype functions with simplified, faster
39+
non-locale-sensitive ones in json_tokener and json_object_to_json_string.
40+
* Neither vertical tab nor formfeed are considered whitespace per the JSON spec
41+
* json_object: speed up creation of objects, calloc() -> malloc() + set fields
42+
* Avoid needless extra strlen() call in json_c_shallow_copy_default() and
43+
json_object_equal() when the object is known to be a json_type_string.
44+
45+
Other changes
46+
-------------
47+
* Validate size arguments in arraylist functions.
48+
* Use getrandom() if available; with GRND_NONBLOCK to allow use of json-c
49+
very early during boot, such as part of cryptsetup.
50+
* Use arc4random() if it's available.
51+
* random_seed: on error, continue to next method instead of exiting the process
52+
* Close file when unable to read from /dev/urandom in get_dev_random_seed()
53+
54+
***
55+
56+
0.15 (up to commit 870965e, 2020/07/26)
57+
========================================
458

559
Deprecated and removed features:
660
--------------------------------
@@ -59,7 +113,7 @@ Other changes
59113
* #589 - Detect broken RDRAND during initialization; also, fix segfault
60114
in the CPUID check.
61115
* #592 - Fix integer overflows to prevert out of bounds write on large input.
62-
* Protect against division by zero in linkhash, when creaed with zero size.
116+
* Protect against division by zero in linkhash, when created with zero size.
63117
* #602 - Fix json_parse_uint64() internal error checking, leaving the retval
64118
untouched in more failure cases.
65119
* #614 - Prevent truncation when custom double formatters insert extra \0's
@@ -185,7 +239,7 @@ Behavior changes:
185239
* Use size_t for array length and size. Platforms where sizeof(size_t) != sizeof(int) may not be backwards compatible
186240
See commits 45c56b, 92e9a5 and others.
187241

188-
* Check for failue when allocating memory, returning NULL and errno=ENOMEM.
242+
* Check for failure when allocating memory, returning NULL and errno=ENOMEM.
189243
See commit 2149a04.
190244

191245
* Change json_object_object_add() return type from void to int, and will return -1 on failures, instead of exiting. (Note: this is not an ABI change)
@@ -376,7 +430,7 @@ List of new functions added:
376430
* Add an alternative iterator implementation, see json_object_iterator.h
377431
* Make json_object_iter public to enable external use of the
378432
json_object_object_foreachC macro.
379-
* Add a printbuf_memset() function to provide an effecient way to set and
433+
* Add a printbuf_memset() function to provide an efficient way to set and
380434
append things like whitespace indentation.
381435
* Adjust json_object_is_type and json_object_get_type so they return
382436
json_type_null for NULL objects and handle NULL passed to
@@ -462,7 +516,7 @@ List of new functions added:
462516
0.7
463517
===
464518
* Add escaping of backslash to json output
465-
* Add escaping of foward slash on tokenizing and output
519+
* Add escaping of forward slash on tokenizing and output
466520
* Changes to internal tokenizer from using recursion to
467521
using a depth state structure to allow incremental parsing
468522

vendor/json-c/arraylist.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ struct array_list *array_list_new2(array_list_free_fn *free_fn, int initial_size
4545
{
4646
struct array_list *arr;
4747

48+
if (initial_size < 0 || (size_t)initial_size >= SIZE_T_MAX / sizeof(void *))
49+
return NULL;
4850
arr = (struct array_list *)malloc(sizeof(struct array_list));
4951
if (!arr)
5052
return NULL;
@@ -106,6 +108,8 @@ int array_list_shrink(struct array_list *arr, size_t empty_slots)
106108
void *t;
107109
size_t new_size;
108110

111+
if (empty_slots >= SIZE_T_MAX / sizeof(void *) - arr->length)
112+
return -1;
109113
new_size = arr->length + empty_slots;
110114
if (new_size == arr->size)
111115
return 0;

vendor/json-c/arraylist.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
* Although this is exposed by the json_object_get_array() method,
1616
* it is not recommended for direct use.
1717
*/
18-
#ifndef _arraylist_h_
19-
#define _arraylist_h_
18+
#ifndef _json_c_arraylist_h_
19+
#define _json_c_arraylist_h_
2020

2121
#ifdef __cplusplus
2222
extern "C" {

vendor/json-c/config-linux.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@
7474
/* Define to 1 if you have the <xlocale.h> header file. */
7575
/* #undef HAVE_XLOCALE_H */
7676

77+
/* Define to 1 if you have the <bsd/stdlib.h> header file. */
78+
/* #undef HAVE_BSD_STDLIB_H */
79+
80+
/* Define to 1 if you have `arc4random' */
81+
/* #undef HAVE_ARC4RANDOM */
82+
7783
/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */
7884
/* #undef HAVE_DOPRNT */
7985

@@ -177,7 +183,7 @@
177183
#define PACKAGE_NAME "json-c"
178184

179185
/* Define to the full name and version of this package. */
180-
#define PACKAGE_STRING "json-c 0.15.99"
186+
#define PACKAGE_STRING "json-c 0.16."
181187

182188
/* Define to the one symbol short name of this package. */
183189
#define PACKAGE_TARNAME "json-c"
@@ -186,7 +192,7 @@
186192
#define PACKAGE_URL "https://github.com/json-c/json-c"
187193

188194
/* Define to the version of this package. */
189-
#define PACKAGE_VERSION "0.15.99"
195+
#define PACKAGE_VERSION "0.16."
190196

191197
/* The number of bytes in type int */
192198
#define SIZEOF_INT 4
@@ -213,7 +219,7 @@
213219
#define STDC_HEADERS
214220

215221
/* Version number of package */
216-
#define VERSION "0.15.99"
222+
#define VERSION "0.16."
217223

218224
/* Define to empty if `const' does not conform to ANSI C. */
219225
/* #undef const */

vendor/json-c/config-macos.h

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@
5656
/* Define to 1 if you have the <sys/param.h> header file. */
5757
#define HAVE_SYS_PARAM_H 1
5858

59+
/* Define to 1 if you have the <sys/random.h> header file. */
60+
#define HAVE_SYS_RANDOM_H
61+
5962
/* Define to 1 if you have the <sys/resource.h> header file. */
6063
#define HAVE_SYS_RESOURCE_H
6164

@@ -71,6 +74,12 @@
7174
/* Define to 1 if you have the <xlocale.h> header file. */
7275
#define HAVE_XLOCALE_H
7376

77+
/* Define to 1 if you have the <bsd/stdlib.h> header file. */
78+
/* #undef HAVE_BSD_STDLIB_H */
79+
80+
/* Define to 1 if you have `arc4random' */
81+
#define HAVE_ARC4RANDOM
82+
7483
/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */
7584
/* #undef HAVE_DOPRNT */
7685

@@ -140,6 +149,9 @@
140149
/* Define to 1 if you have the `vsyslog' function. */
141150
#define HAVE_VSYSLOG 1
142151

152+
/* Define if you have the `getrandom' function. */
153+
/* #undef HAVE_GETRANDOM */
154+
143155
/* Define if you have the `getrusage' function. */
144156
#define HAVE_GETRUSAGE
145157

@@ -171,7 +183,7 @@
171183
#define PACKAGE_NAME "json-c"
172184

173185
/* Define to the full name and version of this package. */
174-
#define PACKAGE_STRING "json-c 0.15."
186+
#define PACKAGE_STRING "json-c 0.16."
175187

176188
/* Define to the one symbol short name of this package. */
177189
#define PACKAGE_TARNAME "json-c"
@@ -180,7 +192,7 @@
180192
#define PACKAGE_URL "https://github.com/json-c/json-c"
181193

182194
/* Define to the version of this package. */
183-
#define PACKAGE_VERSION "0.15."
195+
#define PACKAGE_VERSION "0.16."
184196

185197
/* The number of bytes in type int */
186198
#define SIZEOF_INT 4
@@ -207,7 +219,7 @@
207219
#define STDC_HEADERS
208220

209221
/* Version number of package */
210-
#define VERSION "0.15."
222+
#define VERSION "0.16."
211223

212224
/* Define to empty if `const' does not conform to ANSI C. */
213225
/* #undef const */

vendor/json-c/config-win32.h

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@
5656
/* Define to 1 if you have the <sys/param.h> header file. */
5757
/* #undef HAVE_SYS_PARAM_H */
5858

59+
/* Define to 1 if you have the <sys/random.h> header file. */
60+
/* #undef HAVE_SYS_RANDOM_H */
61+
5962
/* Define to 1 if you have the <sys/resource.h> header file. */
6063
/* #undef HAVE_SYS_RESOURCE_H */
6164

@@ -71,6 +74,12 @@
7174
/* Define to 1 if you have the <xlocale.h> header file. */
7275
/* #undef HAVE_XLOCALE_H */
7376

77+
/* Define to 1 if you have the <bsd/stdlib.h> header file. */
78+
/* #undef HAVE_BSD_STDLIB_H */
79+
80+
/* Define to 1 if you have `arc4random' */
81+
/* #undef HAVE_ARC4RANDOM */
82+
7483
/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */
7584
/* #undef HAVE_DOPRNT */
7685

@@ -140,6 +149,9 @@
140149
/* Define to 1 if you have the `vsyslog' function. */
141150
/* #undef HAVE_VSYSLOG */
142151

152+
/* Define if you have the `getrandom' function. */
153+
/* #undef HAVE_GETRANDOM */
154+
143155
/* Define if you have the `getrusage' function. */
144156
/* #undef HAVE_GETRUSAGE */
145157

@@ -171,7 +183,7 @@
171183
#define PACKAGE_NAME "json-c"
172184

173185
/* Define to the full name and version of this package. */
174-
#define PACKAGE_STRING "json-c 0.15."
186+
#define PACKAGE_STRING "json-c 0.16."
175187

176188
/* Define to the one symbol short name of this package. */
177189
#define PACKAGE_TARNAME "json-c"
@@ -180,7 +192,7 @@
180192
#define PACKAGE_URL "https://github.com/json-c/json-c"
181193

182194
/* Define to the version of this package. */
183-
#define PACKAGE_VERSION "0.15."
195+
#define PACKAGE_VERSION "0.16."
184196

185197
/* The number of bytes in type int */
186198
#define SIZEOF_INT 4
@@ -207,7 +219,7 @@
207219
#define STDC_HEADERS
208220

209221
/* Version number of package */
210-
#define VERSION "0.15."
222+
#define VERSION "0.16."
211223

212224
/* Define to empty if `const' does not conform to ANSI C. */
213225
/* #undef const */

vendor/json-c/debug.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
* @file
1515
* @brief Do not use, json-c internal, may be changed or removed at any time.
1616
*/
17-
#ifndef _DEBUG_H_
18-
#define _DEBUG_H_
17+
#ifndef _JSON_C_DEBUG_H_
18+
#define _JSON_C_DEBUG_H_
1919

2020
#include <stdlib.h>
2121

@@ -24,7 +24,7 @@ extern "C" {
2424
#endif
2525

2626
#ifndef JSON_EXPORT
27-
#if defined(_MSC_VER)
27+
#if defined(_MSC_VER) && defined(JSON_C_DLL)
2828
#define JSON_EXPORT __declspec(dllexport)
2929
#else
3030
#define JSON_EXPORT extern

vendor/json-c/json_c_version.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012,2017,2019,2020 Eric Hawicz
2+
* Copyright (c) 2012,2017-2022 Eric Haszlakiewicz
33
*
44
* This library is free software; you can redistribute it and/or modify
55
* it under the terms of the MIT license. See COPYING for details.
@@ -17,14 +17,14 @@ extern "C" {
1717
#endif
1818

1919
#define JSON_C_MAJOR_VERSION 0
20-
#define JSON_C_MINOR_VERSION 15
20+
#define JSON_C_MINOR_VERSION 16
2121
#define JSON_C_MICRO_VERSION 0
2222
#define JSON_C_VERSION_NUM \
2323
((JSON_C_MAJOR_VERSION << 16) | (JSON_C_MINOR_VERSION << 8) | JSON_C_MICRO_VERSION)
24-
#define JSON_C_VERSION "0.15"
24+
#define JSON_C_VERSION "0.16"
2525

2626
#ifndef JSON_EXPORT
27-
#if defined(_MSC_VER)
27+
#if defined(_MSC_VER) && defined(JSON_C_DLL)
2828
#define JSON_EXPORT __declspec(dllexport)
2929
#else
3030
#define JSON_EXPORT extern

0 commit comments

Comments
 (0)