]> git.ipfire.org Git - thirdparty/json-c.git/log
thirdparty/json-c.git
3 years agoSetted cmake "uninstall" target to exist in unix like operating systems only 718/head
Pawday [Mon, 26 Jul 2021 15:52:29 +0000 (18:52 +0300)] 
Setted cmake "uninstall" target to exist in unix like operating systems only

3 years agoAdd workaround for Visual Studio not knowing about "inline".
Eric Haszlakiewicz [Sun, 25 Jul 2021 20:31:59 +0000 (20:31 +0000)] 
Add workaround for Visual Studio not knowing about "inline".

3 years agoSwitch the Travis build to use osx_image: xcode12.5, in an attempt to avoid timeouts...
Eric Haszlakiewicz [Sun, 25 Jul 2021 20:03:55 +0000 (20:03 +0000)] 
Switch the Travis build to use osx_image: xcode12.5, in an attempt to avoid timeouts with Homebrew.

3 years agoMerge some old work to include (some of) PR #464 into the current master branch.
Eric Haszlakiewicz [Sun, 25 Jul 2021 19:07:06 +0000 (19:07 +0000)] 
Merge some old work to include (some of) PR #464 into the current master branch.

3 years agoOnly define an "uninstall" target if it's not already defined (e.g. by projects that...
Eric Haszlakiewicz [Sun, 25 Jul 2021 15:11:11 +0000 (15:11 +0000)] 
Only define an "uninstall" target if it's not already defined (e.g. by projects that include json-c)

4 years agoMerge pull request #714 from Hex052/clang-format_AfterCaseLabel
Eric Hawicz [Mon, 5 Jul 2021 22:18:06 +0000 (18:18 -0400)] 
Merge pull request #714 from Hex052/clang-format_AfterCaseLabel

Add AfterCaseLabel to .clang-format

4 years agoAdd AfterCaseLabel to .clang-format 714/head
Hex052 [Mon, 5 Jul 2021 02:28:21 +0000 (18:28 -0800)] 
Add AfterCaseLabel to .clang-format

This is to fix the behavior that might've changed between older versions of clang-format, I'm not sure.
Version 10 tries to put the bracket on the same line as case without this.

4 years agoIf inttypes.h is present, use it, even on Windows.
Eric Haszlakiewicz [Sun, 13 Jun 2021 21:12:22 +0000 (21:12 +0000)] 
If inttypes.h is present, use it, even on Windows.

4 years agoIssue #709: adjust some include guards to be a bit more json-c specific.
Eric Haszlakiewicz [Wed, 2 Jun 2021 23:53:23 +0000 (23:53 +0000)] 
Issue #709: adjust some include guards to be a bit more json-c specific.

4 years agoMerge pull request #706 from davidjmccann/master
Eric Hawicz [Sat, 15 May 2021 12:41:24 +0000 (08:41 -0400)] 
Merge pull request #706 from davidjmccann/master

Check __STDC_VERSION__ is defined before checking its value

4 years agoMerge branch 'json-c:master' into master 706/head
David McCann [Thu, 13 May 2021 05:34:10 +0000 (06:34 +0100)] 
Merge branch 'json-c:master' into master

4 years agoCheck __STDC_VERSION__ is defined before checking its value
David McCann [Thu, 13 May 2021 05:31:18 +0000 (06:31 +0100)] 
Check __STDC_VERSION__ is defined before checking its value

Prevent an undef warning regarding __STDC_VERSION__ by checking whether it is defined before checking its value.

4 years agoMerge pull request #696 from ssrlive/master
Eric Hawicz [Sat, 1 May 2021 19:21:31 +0000 (15:21 -0400)] 
Merge pull request #696 from ssrlive/master

To avoid target exe file export JSON functions.

4 years agoMerge pull request #701 from commodo/configurable-opts
Eric Hawicz [Sat, 17 Apr 2021 21:26:49 +0000 (17:26 -0400)] 
Merge pull request #701 from commodo/configurable-opts

[RFC] json_pointer: allow the feature to be disabled

4 years agojson_pointer: allow the feature to be disabled 701/head
Alexandru Ardelean [Fri, 16 Apr 2021 06:42:07 +0000 (09:42 +0300)] 
json_pointer: allow the feature to be disabled

Some users may not want to included it in their build/system. So allow a
cmake symbol to disable it.

A user can do 'cmake -DDISABLE_JSON_POINTER=ON <json_c_root_dir>' and
disable the json_pointer functionality. That saves about 17 KB (on an
x86_64) machine. This may be useful on smaller embedded systems; even
though the saving would be fewer kilobytes.

One thing that also needs to change a bit, is that the 'json.h' be
autogenerated via cmake, in order to conditionally include that
"json_pointer.h" file.

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
4 years agotests: CMakeLists.txt: move test names to variable
Alexandru Ardelean [Fri, 16 Apr 2021 06:32:07 +0000 (09:32 +0300)] 
tests: CMakeLists.txt: move test names to variable

The intent is to be able to disable some features that get built into the
library. When we do that, we also need to disable some tests.

It's easier when adjusting a variable that contains the list of test names,
versus modifying the list in the foreach() statement.

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
4 years agoMerge pull request #700 from Philosoph228/werror-fix
Eric Hawicz [Thu, 15 Apr 2021 02:38:36 +0000 (22:38 -0400)] 
Merge pull request #700 from Philosoph228/werror-fix

Fix unused variable for Win32 build in random_seed.c

4 years agorandom_seed: fix unused variable for win32 build 700/head
Philosoph228 [Mon, 12 Apr 2021 19:12:35 +0000 (00:12 +0500)] 
random_seed: fix unused variable for win32 build

4 years agoTo avoid target exe file export JSON functions. 696/head
ssrlive [Tue, 2 Mar 2021 06:27:40 +0000 (14:27 +0800)] 
To avoid target exe file export JSON functions.

4 years agoAdd a DISABLE_EXTRA_LIBS option to skip using libbsd, per @neheb's request on issue...
Eric Haszlakiewicz [Mon, 15 Feb 2021 20:19:56 +0000 (20:19 +0000)] 
Add a DISABLE_EXTRA_LIBS option to skip using libbsd, per @neheb's request on issue #692/commit 0f61f692.

4 years agoIf arc4random is used, don't bother compiling in the other fallback methods since...
Eric Haszlakiewicz [Sat, 13 Feb 2021 03:23:58 +0000 (03:23 +0000)] 
If arc4random is used, don't bother compiling in the other fallback methods since they'll never be used.  Fixes PR#695 about unreachable code too.

4 years agoMerge pull request #694 from ihsinme/patch-1
Eric Hawicz [Sat, 6 Feb 2021 22:25:24 +0000 (17:25 -0500)] 
Merge pull request #694 from ihsinme/patch-1

fix invalid unsigned arithmetic.

4 years agoUpdate json_object.c 694/head
ihsinme [Fri, 5 Feb 2021 15:58:20 +0000 (18:58 +0300)] 
Update json_object.c

4 years agoIesue #692: use arc4random() if it's available (in libc on BSD systems, and libbsd...
Eric Haszlakiewicz [Wed, 13 Jan 2021 01:57:25 +0000 (01:57 +0000)] 
Iesue #692: use arc4random() if it's available (in libc on BSD systems, and libbsd on Linux).

4 years agoKeep the doc directory in the nodoc release tarball, just exclude its contents.
Eric Haszlakiewicz [Wed, 13 Jan 2021 01:30:16 +0000 (01:30 +0000)] 
Keep the doc directory in the nodoc release tarball, just exclude its contents.

4 years agoMerge pull request #674 from ploxiln/random_seed_err_continue
Eric Hawicz [Wed, 13 Jan 2021 01:22:54 +0000 (20:22 -0500)] 
Merge pull request #674 from ploxiln/random_seed_err_continue

random_seed: on error, continue to next method

4 years agoMerge pull request #689 from neheb/patch-1
Eric Hawicz [Sat, 19 Dec 2020 02:30:14 +0000 (21:30 -0500)] 
Merge pull request #689 from neheb/patch-1

fix compilation with clang

4 years agofix compilation with clang 689/head
Rosen Penev [Fri, 18 Dec 2020 03:59:37 +0000 (19:59 -0800)] 
fix compilation with clang

Fixes the following warning:

json_pointer.c:230:7: warning: implicit declaration of function
    'vasprintf' is invalid in C99 [-Wimplicit-function-declaration]
            rc = vasprintf(&path_copy, path_fmt, args);

4 years agorandom_seed: on error, continue to next method 674/head
Pierce Lopez [Wed, 7 Oct 2020 05:22:30 +0000 (01:22 -0400)] 
random_seed: on error, continue to next method

instead of exiting the process

4 years agoMerge pull request #667 from stoeckmann/regression
Eric Hawicz [Sat, 12 Sep 2020 00:56:51 +0000 (20:56 -0400)] 
Merge pull request #667 from stoeckmann/regression

Fixed test1 regression.

4 years agoFixed test1 regression. 667/head
Tobias Stoeckmann [Fri, 11 Sep 2020 19:09:40 +0000 (21:09 +0200)] 
Fixed test1 regression.

SIZEOF_SIZE_T might be only defined in config.h.

Include config.h for these systems to pass tests which are only
supposed to be run on 32 bit systems.

Fixes issue #666.

4 years agoMerge pull request #665 from stoeckmann/tokener
Eric Hawicz [Mon, 24 Aug 2020 13:51:41 +0000 (09:51 -0400)] 
Merge pull request #665 from stoeckmann/tokener

Handle more allocation failures in json_tokener* functions

4 years agoMerge pull request #660 from stoeckmann/arraylist
Eric Hawicz [Mon, 24 Aug 2020 13:51:18 +0000 (09:51 -0400)] 
Merge pull request #660 from stoeckmann/arraylist

Validate size arguments in arraylist functions.

4 years agoValidate size arguments in arraylist functions. 660/head
Tobias Stoeckmann [Sat, 22 Aug 2020 10:06:15 +0000 (12:06 +0200)] 
Validate size arguments in arraylist functions.

The array_list_new2 function, which is externally reachable through
json_object_new_array_ext, does not check if specified initial size
actually fits into memory on 32 bit architectures.

It also allows negative values, which could lead to an overflow on these
architectures as well. I have added test cases for these situations.

While at it, also protect array_list_shrink against too large
empty_slots argument. No test added because it takes a huge length
value, therefore a lot of items within the array, to overflow the
calculation. In theory this affects 64 bit sytems as well, but since the
arraylist API is not supposed to be used by external applications
according to its header file, the call is protected due to int
limitation of json_object_array_shrink.

4 years agoMerge pull request #664 from stoeckmann/string
Eric Hawicz [Sun, 23 Aug 2020 20:43:31 +0000 (16:43 -0400)] 
Merge pull request #664 from stoeckmann/string

Limit strings at INT_MAX length

4 years agoMerge pull request #663 from stoeckmann/strerror
Eric Hawicz [Sun, 23 Aug 2020 20:38:21 +0000 (16:38 -0400)] 
Merge pull request #663 from stoeckmann/strerror

Properly format errnos in _json_c_strerror

4 years agoMerge pull request #662 from stoeckmann/random
Eric Hawicz [Sun, 23 Aug 2020 20:34:40 +0000 (16:34 -0400)] 
Merge pull request #662 from stoeckmann/random

Prevent signed overflow in get_time_seed

4 years agoPrevent signed overflow in get_time_seed 662/head
Tobias Stoeckmann [Sat, 22 Aug 2020 11:23:23 +0000 (13:23 +0200)] 
Prevent signed overflow in get_time_seed

Casting time(2) return value to int and multiplying the result with
such a constant will definitely lead to a signed overflow by this day.

Since signed overflows are undefined behaviour in C, avoid this.

Casting to unsigned is more than enough since the upper bits of a
64 bit time_t value will be removed with the int conversion anyway.

4 years agoHandle allocation failure in json_tokener_new_ex 665/head
Tobias Stoeckmann [Sat, 22 Aug 2020 11:18:10 +0000 (13:18 +0200)] 
Handle allocation failure in json_tokener_new_ex

The allocation of printbuf_new might fail. Return NULL to indicate tis
error to the caller. Otherwise later usage of the returned tokener would
lead to null pointer dereference.

4 years agoCap string length at INT_MAX. 664/head
Tobias Stoeckmann [Sat, 22 Aug 2020 11:09:11 +0000 (13:09 +0200)] 
Cap string length at INT_MAX.

Several issues occur if a string is longer than INT_MAX:

- The function json_object_get_string_len returns the length of a string
  as int. If the string is longer than INT_MAX, the result would be
  negative.
- That in turn would lead to possible out of boundary access when
  comparing these strings with memcmp and the returned length as done in
  json_object_equal.
- If json_escape_str is called with such strings, out of boundary
  accesses can occur due to internal int handling (also fixed).
- The string cannot be printed out due to printbuffer limits at
  INT_MAX (which is still true after this commit).

Such huge strings can only be inserted through API calls at this point
because input files are capped at INT_MAX anyway.

Due to huge amount of RAM needed to reproduce these issues I have not
added test cases.

4 years agoAligned comment in _json_object_new_string
Tobias Stoeckmann [Sat, 22 Aug 2020 11:07:45 +0000 (13:07 +0200)] 
Aligned comment in _json_object_new_string

The comment only aligns correctly if tab size is 4. Replaced
spaces with tabs to stay in sync with style of other lines.

4 years agoProperly format errnos in _json_c_strerror 663/head
Tobias Stoeckmann [Sat, 22 Aug 2020 09:35:50 +0000 (11:35 +0200)] 
Properly format errnos in _json_c_strerror

The function _json_c_strerror does not properly format unknown errnos.
The int to ascii loop ignores the leading digit if the number can be
divided by 10 and if an errno has been formatted, shorter errnos would
not properly terminate the newly created string, showing the ending
numbers of the previous output.

A test case has been added to show these effects.

Since this function has been introduced for tests, the effect of this on
real life code is basically non-existing. First an environment variable
has to be set to activate this strerror code and second an unknown errno
would have to be encountered.

4 years agoFix json_object_get_boolean() doc for the object and array cases (always returns...
Eric Haszlakiewicz [Mon, 17 Aug 2020 14:55:54 +0000 (14:55 +0000)] 
Fix json_object_get_boolean() doc for the object and array cases (always returns 0), and add those cases to the test_cast test.
See also issue #658.

4 years agoMerge pull request #657 from stoeckmann/getrandom
Eric Hawicz [Sat, 15 Aug 2020 19:01:41 +0000 (15:01 -0400)] 
Merge pull request #657 from stoeckmann/getrandom

Use GRND_NONBLOCK with getrandom.

4 years agoUse GRND_NONBLOCK with getrandom. 657/head
Tobias Stoeckmann [Sat, 15 Aug 2020 13:41:41 +0000 (15:41 +0200)] 
Use GRND_NONBLOCK with getrandom.

The json-c library is used in cryptsetup for LUKS2 header information.
Since cryptsetup can be called very early during boot, the developers
avoid getrandom() calls in their own code base for now. [1]

Introducing a blocking getrandom() call in json-c therefore introduces
this issue for cryptsetup as well. Even though cryptsetup issues do not
have to be json-c issues, here is my proposal:

Let's use a non-blocking call, falling back to other sources if the call
would block. Since getrandom() accesses urandom, it must mean that we
are in an early boot phase -- otherwise the call would not block
according to its manual page.

As stated in manual page of random(4), accessing /dev/urandom won't
block but return weak random numbers, therefore this fallback would work
for json-c.

While at it, fixed the debug message.

[1] https://gitlab.com/cryptsetup/cryptsetup/-/merge_requests/47
    which references to https://lwn.net/Articles/800509/

4 years agoMerge pull request #656 from pogaram/fix-warnings
Eric Hawicz [Fri, 14 Aug 2020 20:57:32 +0000 (16:57 -0400)] 
Merge pull request #656 from pogaram/fix-warnings

Fixed warnings

4 years agoFixed warnings 656/head
Aram Poghosyan [Fri, 14 Aug 2020 07:45:33 +0000 (11:45 +0400)] 
Fixed warnings

4 years agoMerge pull request #655 from MarcT512/issue654
Eric Hawicz [Fri, 7 Aug 2020 14:18:30 +0000 (10:18 -0400)] 
Merge pull request #655 from MarcT512/issue654

json_parse: Fix read past end of buffer

4 years agoFix read past end of buffer 655/head
Marc [Fri, 7 Aug 2020 09:49:45 +0000 (10:49 +0100)] 
Fix read past end of buffer

Resolves https://github.com/json-c/json-c/issues/654

4 years agoEliminate use of ctype.h and replace isdigit() and tolower() with non-locale-sensitiv...
Eric Haszlakiewicz [Sun, 2 Aug 2020 04:06:44 +0000 (04:06 +0000)] 
Eliminate use of ctype.h and replace isdigit() and tolower() with non-locale-sensitive approaches.

4 years agoNeither vertical tab nor formfeed are considered whitespace per the JSON spec, remove...
Eric Haszlakiewicz [Sun, 2 Aug 2020 03:59:56 +0000 (03:59 +0000)] 
Neither vertical tab nor formfeed are considered whitespace per the JSON spec, remove them from is_ws_char().

4 years agoMerge the is_ws_char() and is_hex_char() changes to json_tokener from branch 'ramirop...
Eric Haszlakiewicz [Sun, 2 Aug 2020 02:54:36 +0000 (02:54 +0000)] 
Merge the is_ws_char() and is_hex_char() changes to json_tokener from branch 'ramiropolla/for_upstream' (PR #464)

4 years agoTake a hint from PR #464 and use json_object_new_string_len() to avoid a needless...
Eric Haszlakiewicz [Sun, 2 Aug 2020 02:23:01 +0000 (02:23 +0000)] 
Take a hint from PR #464 and use json_object_new_string_len() to avoid a needless extra strlen() call.
Also, create a _json_object_get_string_len() for internal use when we know
for sure the object we're dealing with is a json_type_string.

4 years agoMerge pull request #653 from lamby/966657-json-c-please-make-the-build-reproducible
Eric Hawicz [Sun, 2 Aug 2020 02:06:38 +0000 (22:06 -0400)] 
Merge pull request #653 from lamby/966657-json-c-please-make-the-build-reproducible

Make the documentation build reproducibly

4 years agoMake the documentation build reproducibly 653/head
Chris Lamb [Sat, 1 Aug 2020 10:26:53 +0000 (11:26 +0100)] 
Make the documentation build reproducibly

Whilst working on the Reproducible Builds effort [0] I noticed that
json-c could not be built reproducibly.

This is because it used the full, absolute path name as an (sanitised)
input to a filename, resulting in some binary package containing, for
example:

  /usr/share/doc/libjson-c-dev/html/md__build_1st_json-c-0_815_issues_closed_for_0_813.html
                                        ^^^^^^^^^^^^^^^^^^^^^^
or

  /usr/share/doc/libjson-c-dev/html/md__build_2_json-c-0_815_2nd_issues_closed_for_0_813.html
                                        ^^^^^^^^^^^^^^^^^^^^^^^^

These differing values are based on the path in which json-c is built. This was
originally filed in Debian as #966657 [1].

 [0] https://reproducible-builds.org/
 [1] https://bugs.debian.org/966657

4 years agoMerge pull request #651 from alanc/getrandom
Eric Hawicz [Sat, 1 Aug 2020 00:30:11 +0000 (20:30 -0400)] 
Merge pull request #651 from alanc/getrandom

Getrandom

4 years agoUse getrandom() if available in json_c_get_random_seed 651/head
Alan Coopersmith [Thu, 30 Jul 2020 23:13:04 +0000 (16:13 -0700)] 
Use getrandom() if available in json_c_get_random_seed

Lower overhead than opening & reading from /dev/urandom, and works
in chroots and other situtations where /dev/urandom is not available.
Falls back to existing methods when kernel doesn't support the syscall.

4 years agoIssue #649: Drop the generated doc/Doxyfile when creating a release.
Eric Haszlakiewicz [Tue, 28 Jul 2020 03:52:22 +0000 (03:52 +0000)] 
Issue #649: Drop the generated doc/Doxyfile when creating a release.

4 years agoMerge pull request #650 from sartura/readme-update
Eric Hawicz [Mon, 27 Jul 2020 14:31:05 +0000 (10:31 -0400)] 
Merge pull request #650 from sartura/readme-update

README: fix spelling errors

4 years agoREADME: fix spelling errors 650/head
Jakov Smolic [Mon, 27 Jul 2020 08:30:08 +0000 (10:30 +0200)] 
README: fix spelling errors

Signed-off-by: Jakov Smolic <jakov.smolic@sartura.hr>
4 years agoInclude updating the json-c-current-releaes gh-pages symlink as part of the release...
Eric Haszlakiewicz [Sun, 26 Jul 2020 15:51:07 +0000 (15:51 +0000)] 
Include updating the json-c-current-releaes gh-pages symlink as part of the release process.

4 years agoUpdate the master branch to version 0.15.99
Eric Haszlakiewicz [Sun, 26 Jul 2020 15:26:05 +0000 (15:26 +0000)] 
Update the master branch to version 0.15.99

4 years agoUpdate AUTHORS, add issues_closed_for_0.15.md, tweak the release checklist slightly.
Eric Haszlakiewicz [Fri, 24 Jul 2020 03:17:13 +0000 (03:17 +0000)] 
Update AUTHORS, add issues_closed_for_0.15.md, tweak the release checklist slightly.

4 years agoMerge pull request #648 from MarcT512/rbf
Eric Hawicz [Fri, 24 Jul 2020 02:26:58 +0000 (22:26 -0400)] 
Merge pull request #648 from MarcT512/rbf

Fix "may be used uninitialized" Release build failure

4 years agoFix "may be used uninitialized" Release build failure 648/head
Marc [Thu, 23 Jul 2020 17:19:12 +0000 (18:19 +0100)] 
Fix "may be used uninitialized" Release build failure

Fixes https://github.com/json-c/json-c/issues/647

4 years agoIssue #594 - provide an OVERRIDE_GET_RANDOM_SEED cmake variable to override json_c_ge...
Eric Haszlakiewicz [Wed, 22 Jul 2020 02:25:03 +0000 (02:25 +0000)] 
Issue #594 - provide an OVERRIDE_GET_RANDOM_SEED cmake variable to override json_c_get_random_seed() for embedded platforms where time(NULL) doesn't work.

Example:
mkdir build && cd build
cmake -DOVERRIDE_GET_RANDOM_SEED='do { extern uint32_t getMsTicks(void); int ms = getMsTicks() * 433494437; return ms; } while(0)' ..

4 years agoMerge pull request #646 from pascal-cuoq/fix_645
Eric Hawicz [Wed, 22 Jul 2020 01:24:59 +0000 (21:24 -0400)] 
Merge pull request #646 from pascal-cuoq/fix_645

Cast to unsigned char instead of int when calling tolower (Fixes #645)

4 years agoFixes #645 646/head
Pascal Cuoq [Tue, 21 Jul 2020 15:54:26 +0000 (17:54 +0200)] 
Fixes #645

4 years agoUpdate the ChangeLog with recent changes, in preparation for a 0.15 release.
Eric Haszlakiewicz [Mon, 20 Jul 2020 03:39:01 +0000 (03:39 +0000)] 
Update the ChangeLog with recent changes, in preparation for a 0.15 release.

4 years agoRemove the obsolete config.h.win32
Eric Haszlakiewicz [Fri, 17 Jul 2020 03:47:28 +0000 (03:47 +0000)] 
Remove the obsolete config.h.win32

4 years agoFix a number of things with the generated docs, including translating triple-backtick...
Eric Haszlakiewicz [Fri, 17 Jul 2020 03:46:21 +0000 (03:46 +0000)] 
Fix a number of things with the generated docs, including translating triple-backtick code blocks into a form doxygen understands.

4 years agoAdd some more detail about how to use json-c in README.md.
Eric Haszlakiewicz [Fri, 17 Jul 2020 03:42:38 +0000 (03:42 +0000)] 
Add some more detail about how to use json-c in README.md.

4 years agoRemove the THIS_FUNCTION_IS_DEPRECATED define, we stopped using it long ago.
Eric Haszlakiewicz [Fri, 17 Jul 2020 03:20:29 +0000 (03:20 +0000)] 
Remove the THIS_FUNCTION_IS_DEPRECATED define, we stopped using it long ago.

5 years agoRemove the obsolete README.json_object-split.md, and mark README.md as being the...
Eric Haszlakiewicz [Sun, 12 Jul 2020 19:16:19 +0000 (19:16 +0000)] 
Remove the obsolete README.json_object-split.md, and mark README.md as being the doxygen mainpage.

5 years agoIssue #642: improve the docs for json_object_put() and json_object_get().
Eric Haszlakiewicz [Sun, 12 Jul 2020 18:43:27 +0000 (18:43 +0000)] 
Issue #642: improve the docs for json_object_put() and json_object_get().

5 years agoExpand the doc for json_object_array_get_idx() to explain that it does not adjust...
Eric Haszlakiewicz [Sun, 12 Jul 2020 17:55:46 +0000 (17:55 +0000)] 
Expand the doc for json_object_array_get_idx() to explain that it does not adjust refcounts.

5 years agoIssue #641: Add a cast to void * to address some theoretically undefined printf behavior.
Eric Haszlakiewicz [Sat, 11 Jul 2020 15:03:00 +0000 (15:03 +0000)] 
Issue #641: Add a cast to void * to address some theoretically undefined printf behavior.

5 years agoIssue #642: improve docs for json_tokener.h and json_object_object_add().
Eric Haszlakiewicz [Sat, 11 Jul 2020 04:04:58 +0000 (04:04 +0000)] 
Issue #642: improve docs for json_tokener.h and json_object_object_add().

5 years agoDon't export json-c symbols starting with an underscore, put deprecated exports into...
Eric Haszlakiewicz [Sat, 4 Jul 2020 18:58:56 +0000 (18:58 +0000)] 
Don't export json-c symbols starting with an underscore, put deprecated exports into a "JSONC_PRIVATE" version, and note stuff to do during releases.
See also PR #639 and issue #621

5 years agoChange the strerror_override handling to check $_JSON_C_STRERROR_OVERRIDE instead...
Eric Haszlakiewicz [Sat, 4 Jul 2020 18:56:15 +0000 (18:56 +0000)] 
Change the strerror_override handling to check $_JSON_C_STRERROR_OVERRIDE instead of using a variable, so we don't need to export it.

5 years agoMerge pull request #639 from smcv/symbol-versions
Eric Hawicz [Sat, 4 Jul 2020 18:26:20 +0000 (14:26 -0400)] 
Merge pull request #639 from smcv/symbol-versions

build: Add a symbol version to all exported symbols

5 years agobuild: Add symbol versions to all exported symbols 639/head
Simon McVittie [Mon, 29 Jun 2020 17:16:34 +0000 (18:16 +0100)] 
build: Add symbol versions to all exported symbols

With this version script, newly-linked binaries that depend on the
json-c shared library will refer to its symbols in a versioned form,
preventing their references from being resolved to a symbol of the same
name exported by json-glib or libjansson if those libraries appear in
dependency search order before json-c, which will usually result in
a crash. This is necessary because ELF symbol resolution normally uses
a single flat namespace, not a tree like Windows symbol resolution.
At least one symbol (json_object_iter_next()) is exported by all three
JSON libraries.

Linking with -Bsymbolic is not enough to have this effect in all cases,
because -Bsymbolic only affects symbol lookup within a shared object,
for example when json_object_set_serializer() calls
json_object_set_userdata(). It does not affect calls from external
code into json-c, unless json-c was statically linked into the
external caller.

This change will also not prevent code that depends on json-glib or
libjansson from finding json-c's symbols and crashing; to prevent
that, a corresponding change in json-glib or libjansson would be needed.

Adding a symbol-version is a backwards-compatible change, but once
added, removing or changing the symbol-version on a symbol would be an
incompatible change that requires a SONAME bump.

Resolves: https://github.com/json-c/json-c/issues/621
(when combined with an equivalent change to libjansson).

Signed-off-by: Simon McVittie <smcv@collabora.com>
5 years agoUse constants referring to the signed integer types when setting SSIZE_T_MAX.
Eric Haszlakiewicz [Wed, 1 Jul 2020 00:34:46 +0000 (00:34 +0000)] 
Use constants referring to the signed integer types when setting SSIZE_T_MAX.
In practice, the sizes of the signed and unsigned integer types will
almost cetainly be the same, but this is more correct.
Pointed out in issue #638.

5 years agoReplace one call to json_object_new_array() with json_object_new_array_ext() to ensur...
Eric Haszlakiewicz [Mon, 29 Jun 2020 02:35:26 +0000 (02:35 +0000)] 
Replace one call to json_object_new_array() with json_object_new_array_ext() to ensure it at least minimally works.

5 years agoAdd doc comment for json_object_new_array_ext().
Eric Haszlakiewicz [Mon, 29 Jun 2020 02:31:32 +0000 (02:31 +0000)] 
Add doc comment for json_object_new_array_ext().

5 years agoFix code formatting
Eric Haszlakiewicz [Mon, 29 Jun 2020 02:31:18 +0000 (02:31 +0000)] 
Fix code formatting

5 years agoMake sure TEST_PARSE_CHUNKSIZE is valid if it's set.
Eric Haszlakiewicz [Mon, 29 Jun 2020 02:18:34 +0000 (02:18 +0000)] 
Make sure TEST_PARSE_CHUNKSIZE is valid if it's set.

5 years agoIn the json_tokener_state_number case, explicitly adjust what "number" characters...
Eric Haszlakiewicz [Mon, 29 Jun 2020 02:14:26 +0000 (02:14 +0000)] 
In the json_tokener_state_number case, explicitly adjust what "number" characters are allowed based on the exact micro-state that we're in, and check for invalid following characters in a different way, to allow a valid json_type_number object to be returned at the top level.
This causes previously failing strings like "123-456" to return a valid json_object with the appropriate value.  If you care about the trailing content, call json_tokener_parse_ex() and check the parse end point with json_tokener_get_parse_end().

5 years agoFix incremental parsing of invalid numbers with exponents, such as "0e+-" and "12...
Eric Haszlakiewicz [Sat, 27 Jun 2020 15:32:19 +0000 (15:32 +0000)] 
Fix incremental parsing of invalid numbers with exponents, such as "0e+-" and "12.3E12E12", while still allowing "0e+" in non-strict mode.
Deprecate the json_parse_double() function from json_util.h

5 years agoIssue #635: Fix "expression has no effect" warning in json_tokener.c by casting to...
Eric Haszlakiewicz [Tue, 23 Jun 2020 02:51:46 +0000 (02:51 +0000)] 
Issue #635: Fix "expression has no effect" warning in json_tokener.c by casting to void.

5 years agoFix memory leak in test_parse's single_incremental_parse().
Eric Haszlakiewicz [Mon, 22 Jun 2020 01:12:03 +0000 (01:12 +0000)] 
Fix memory leak in test_parse's single_incremental_parse().

5 years agoDrop extra blank lines from arraylist.h
Eric Haszlakiewicz [Sun, 21 Jun 2020 18:30:40 +0000 (18:30 +0000)] 
Drop extra blank lines from arraylist.h

5 years agoIssue #616: Change the parsing of surrogate pairs in unicode escapes so it uses a...
Eric Haszlakiewicz [Sun, 21 Jun 2020 18:17:40 +0000 (18:17 +0000)] 
Issue #616: Change the parsing of surrogate pairs in unicode escapes so it uses a couple of additional states instead of assuming the low surrogate is already present, to ensure that we correctly handle various cases of incremental parsing.

5 years agoIn test_parse, fix lengths passed during a couple of incremental tests.
Eric Haszlakiewicz [Sun, 21 Jun 2020 17:36:38 +0000 (17:36 +0000)] 
In test_parse, fix lengths passed during a couple of incremental tests.
Add an optional way to use an incremental chunk size ($TEST_PARSE_CHUNKSIZE)
for all of the single_basic_parse tests, in additional to the regular way.

5 years agoRearrange the json_tokener_state_escape_unicode case in json_tokener to simplify...
Eric Haszlakiewicz [Sun, 21 Jun 2020 03:10:55 +0000 (03:10 +0000)] 
Rearrange the json_tokener_state_escape_unicode case in json_tokener to simplify the code slightly and make it a bit easier to understand.
While here, drop the utf8_replacement_char that is unnecesarily added if we run out of input in the middle of a unicode escape.  No other functional changes (yet).

5 years agoUpdate the json_tokener_parse_ex() docs to clarify that the final '\0' character...
Eric Haszlakiewicz [Sun, 21 Jun 2020 02:35:42 +0000 (02:35 +0000)] 
Update the json_tokener_parse_ex() docs to clarify that the final '\0' character is to be included in length passed in.

5 years agoMerge pull request #633 from dota17/issue616
Eric Hawicz [Sun, 21 Jun 2020 02:33:17 +0000 (22:33 -0400)] 
Merge pull request #633 from dota17/issue616

fix issue 616: support the surrogate pair in split file.

5 years agoAdd json_object_array_shrink() (and array_list_shrink()) and use it in json_tokener...
Eric Haszlakiewicz [Sat, 20 Jun 2020 18:03:04 +0000 (18:03 +0000)] 
Add json_object_array_shrink() (and array_list_shrink()) and use it in json_tokener to minimize the amount of memory used.  This results in a 39%-50% reduction in memory use (peak RSS, peak heap usage) on the jc-bench benchmark and 9% shorter runtime.
Also add the json_object_new_array_ext, array_list_new2, and array_list_shrink functions.

5 years agoMerge pull request #632 from json-c/json_object-split
Eric Hawicz [Sat, 20 Jun 2020 17:04:32 +0000 (13:04 -0400)] 
Merge pull request #632 from json-c/json_object-split

Json object split

5 years agoReformat the json_object-split branch with clang-format json_object-split 632/head
Eric Haszlakiewicz [Tue, 16 Jun 2020 13:17:58 +0000 (13:17 +0000)] 
Reformat the json_object-split branch with clang-format