]> git.ipfire.org Git - thirdparty/json-c.git/log
thirdparty/json-c.git
7 months agotokener_parse_ex_fuzzer: add type checking for parsed object 837/head
HansolChoe [Thu, 19 Oct 2023 07:33:01 +0000 (16:33 +0900)] 
tokener_parse_ex_fuzzer: add type checking for parsed object

8 months agoTake 2 fixing the placement of json_tokener_error_memory in the enum. (json_tokener_...
Eric Hawicz [Sat, 23 Sep 2023 02:26:21 +0000 (22:26 -0400)] 
Take 2 fixing the placement of json_tokener_error_memory in the enum.  (json_tokener_error_size is an actual error, *not* a measure of the size of the enum!)

9 months agoMerge pull request #827 from robert-pang/master
Eric Hawicz [Sun, 10 Sep 2023 22:13:45 +0000 (00:13 +0200)] 
Merge pull request #827 from robert-pang/master

Resolve build issue in tokener_parse_ex_fuzzer.c

9 months agoMerge pull request #826 from emlix/cmake-policies
Eric Hawicz [Sun, 10 Sep 2023 22:10:55 +0000 (00:10 +0200)] 
Merge pull request #826 from emlix/cmake-policies

CMake: remove needless policy setting

9 months agoFix variable and API names in tokener_parse_ex_fuzzer.cc to resolve build issue. 827/head
Robert Pang [Tue, 5 Sep 2023 20:58:51 +0000 (13:58 -0700)] 
Fix variable and API names in tokener_parse_ex_fuzzer.cc to resolve build issue.

9 months agoCMake: request all policies up to CMake 3.12 being set to NEW 826/head
Rolf Eike Beer [Tue, 5 Sep 2023 12:31:24 +0000 (14:31 +0200)] 
CMake: request all policies up to CMake 3.12 being set to NEW

9 months agoCMake: request consistent minimum version
Rolf Eike Beer [Tue, 5 Sep 2023 12:27:27 +0000 (14:27 +0200)] 
CMake: request consistent minimum version

9 months agoCMake: remove needless policy setting
Rolf Eike Beer [Tue, 5 Sep 2023 10:14:46 +0000 (12:14 +0200)] 
CMake: remove needless policy setting

These policies were all introduced before CMake 3.9, so they will automatically
be initialized to the new behavior when requesting a minimum version of 3.9.

10 months agoUpdate the master branch to version 0.17.99
Eric Haszlakiewicz [Sat, 12 Aug 2023 19:08:59 +0000 (19:08 +0000)] 
Update the master branch to version 0.17.99

10 months agoAdd an abi-check.sh script that shows how to run the abi-compliance-checker, update...
Eric Hawicz [Sat, 12 Aug 2023 18:34:35 +0000 (14:34 -0400)] 
Add an abi-check.sh script that shows how to run the abi-compliance-checker, update release creation steps slightly.

10 months agoAlso fix messages returned from json_tokener_error_desc() (broke due to the ordering...
Eric Haszlakiewicz [Sat, 12 Aug 2023 18:52:32 +0000 (18:52 +0000)] 
Also fix messages returned from json_tokener_error_desc() (broke due to the ordering change of enum json_tokener_error)

10 months agoMove the json_tokener_error_memory entry to the end of enum json_tokener_error to...
Eric Hawicz [Sat, 12 Aug 2023 17:54:50 +0000 (13:54 -0400)] 
Move the json_tokener_error_memory entry to the end of enum json_tokener_error to restore binary compatibility with 0.16

10 months agoUpdate the AUTHORS file and add issues_closed_for_0.17.md for the upcoming 0.17 release
Eric Hawicz [Sat, 12 Aug 2023 17:53:27 +0000 (13:53 -0400)] 
Update the AUTHORS file and add issues_closed_for_0.17.md for the upcoming 0.17 release

10 months agoUpdate the ChangeLog for 0.17 based on notable commits since 0.16
Eric Hawicz [Tue, 8 Aug 2023 21:31:38 +0000 (17:31 -0400)] 
Update the ChangeLog for 0.17 based on notable commits since 0.16

10 months agoFix issue #823: add back json_number_chars, but only because it's part of the public...
Eric Hawicz [Sun, 6 Aug 2023 19:35:04 +0000 (15:35 -0400)] 
Fix issue #823: add back json_number_chars, but only because it's part of the public API.

10 months agoMerge pull request #679 from GitMensch/patch-1
Eric Hawicz [Sun, 6 Aug 2023 02:32:37 +0000 (22:32 -0400)] 
Merge pull request #679 from GitMensch/patch-1

Let json-c be used with obsolete compilers

10 months agoPR #679: add workaround for old compilers w/o stdint.h (i.e. VS2008 and earlier) 679/head
Eric Hawicz [Sun, 6 Aug 2023 02:11:30 +0000 (22:11 -0400)] 
PR #679: add workaround for old compilers w/o stdint.h (i.e. VS2008 and earlier)

10 months agoMerge pull request #822 from SSharshunov/master
Eric Hawicz [Fri, 4 Aug 2023 15:47:23 +0000 (11:47 -0400)] 
Merge pull request #822 from SSharshunov/master

Added option to disable app build

10 months agoAdded option to disable app build 822/head
Sergey Sharshunov [Fri, 4 Aug 2023 14:46:50 +0000 (19:46 +0500)] 
Added option to disable app build

10 months agoMerge pull request #702 from commodo/json_patch
Eric Hawicz [Tue, 1 Aug 2023 02:19:30 +0000 (22:19 -0400)] 
Merge pull request #702 from commodo/json_patch

json_patch: add first implementation only with patch application

10 months agoDon't export json_pointer_get_internal, move json_object_array_insert_idx and json_pa... 702/head
Eric Hawicz [Sun, 30 Jul 2023 01:45:16 +0000 (21:45 -0400)] 
Don't export json_pointer_get_internal, move json_object_array_insert_idx and json_patch_apply to the JSONC_0.17 section in json-c.sym

10 months agoWork around a somewhat misleading warning about "a function declaration without a...
Eric Hawicz [Sat, 29 Jul 2023 15:22:12 +0000 (11:22 -0400)] 
Work around a somewhat misleading warning about "a function declaration without a prototype is deprecated in all versions of C" in test1.c

10 months agoFix json_patch_apply handling of removing the whole document (i.e. "path":"").
Eric Hawicz [Sat, 29 Jul 2023 02:12:51 +0000 (22:12 -0400)] 
Fix json_patch_apply handling of removing the whole document (i.e. "path":"").
Enable all disabled tests, add a few more including some with null documents.

10 months agoAdjust the behavior of the args passed to json_patch_apply to make it easier to do...
Eric Hawicz [Thu, 27 Jul 2023 02:01:04 +0000 (22:01 -0400)] 
Adjust the behavior of the args passed to json_patch_apply to make it easier to do in place modifications, and add a struct json_patch_error to report more details on failures.

10 months agoFix an uninitialized memory access in json_pointer.
Eric Hawicz [Wed, 26 Jul 2023 22:15:07 +0000 (18:15 -0400)] 
Fix an uninitialized memory access in json_pointer.
Add comments describing when the fields of the internal struct json_pointer_get_result are valid.

10 months agoCreate a json_pointer_private.h and move a few things there, fix test warnings, note...
Eric Hawicz [Sun, 16 Jul 2023 14:48:20 +0000 (10:48 -0400)] 
Create a json_pointer_private.h and move a few things there, fix test warnings, note array_list_insert_idx is private.

10 months agotests: test_json_patch: add test suite for JSON patch
Alexandru Ardelean [Tue, 20 Apr 2021 12:47:18 +0000 (15:47 +0300)] 
tests: test_json_patch: add test suite for JSON patch

Essentially, this change adds the test cases from this repo:
   https://github.com/json-patch/json-patch-tests

Specifically:
   https://github.com/json-patch/json-patch-tests/blob/master/spec_tests.json
   https://github.com/json-patch/json-patch-tests/blob/master/tests.json

The files were taken at the date of this commit, at git hash
  ea3af85790cb72893d0676597814b7532019c24e

Some tests may not have an 'expected' or 'error' field. Those are ignored.
One test was disabled manually via "disabled_in_json_c", because it tries
an impossible test, i.e. to add 2 "op" fields in the same patch entry,
something which is impossible in a JSON object.

For the 'error' cases, right now we only test that an error happens.
Later, we can extend this to check the error codes.

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
10 months agojson_patch: add first implementation only with patch application
Alexandru Ardelean [Sat, 24 Apr 2021 14:00:13 +0000 (17:00 +0300)] 
json_patch: add first implementation only with patch application

Initially I wanted to also do a function that generates the JSON patch from
two JSON documents, but even just applying the JSON patch was a bit of
work, especially when needing to satisfy all the test-cases.

This change defines all the operation in the RFC6902. The addition isn't
too big (for the json_patch_apply() function), as part of the heavy lifting
is also done by JSON pointer logic.

All the ops were tested with the test-cases defined at:
  https://github.com/json-patch/json-patch-tests

RFC6902: https://tools.ietf.org/html/rfc6902

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
10 months agojson_pointer: split json_pointer_set_with_array_cb()
Alexandru Ardelean [Fri, 23 Apr 2021 18:56:29 +0000 (21:56 +0300)] 
json_pointer: split json_pointer_set_with_array_cb()

JSON patch is a bit more clear on how some array operations should be
handled. Unfortunately, handling them on a case-by-case is a bit tricky
because it's difficult to satisfy properly an 'add' operating with a 'move'
operation and the basic json_pointer_set().

With json_pointer_set{f}() we use json_object_array_put_idx() to insert a
value at a certain index.

With JSON patch:
* for the 'add' operation, we need to insert a value at a given index,
  which means shifting existing values by one to the right
  - also, we cannot allow values to be inserted/added outside the bounds of
    the array
* a 'move' operation, is described as a 'remove' and then an 'add';
  for arrays this complicates things, because when we want to a move a
  value within the array, we have to remove it first (during which the size
  of the array is reduced by one); when the size of the array is reduced by
  one, we can't add it to the last position in the array (before the
  remove)

The only sane method to handle this (after a few considerations) is to
provide a callback to the function that does the final put/insert into
the array. That way, we can do some final checks where these are needed to
handle each corner-case.

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
10 months agojson_pointer: move array out-of-bounds check outside of is_valid_index()
Alexandru Ardelean [Fri, 23 Apr 2021 18:19:49 +0000 (21:19 +0300)] 
json_pointer: move array out-of-bounds check outside of is_valid_index()

The out-of-bounds check is useful when trying to index/obtain a value from
an array.
However, when we set a value to a specific JSON pointer, we can allow
values that are outside the length of the current array.
The RFC6901 doc isn't clear on that aspect, and doing so is a bit more
in-line with how json_object_array_{put,insert}_idx() functions behave.

This changes the behavior of json_pointer_set{f}() because now a value can
be set anywhere in the array.

Also, added a test-case for this behavior change.

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
10 months agojson_pointer: introduce json_pointer_get_internal() for internal usage
Alexandru Ardelean [Tue, 20 Apr 2021 13:23:47 +0000 (16:23 +0300)] 
json_pointer: introduce json_pointer_get_internal() for internal usage

For JSON patch, we require that we get access to the parent of a JSON
object as well in order to do some operations via the API.

For example, given the object:
{
  "foo": "bar",
  "array", [ 1, 2, 3]
}

Using JSON pointer with the path
 * '/foo' will return 'bar' of type string
 * '/array/0' will return '1', of type integer

The problem is, that if we do 'json_object_put()' on any of the objects
above, this will not detach them from the parent, because there is no
information back to the parent.

One way to fix this, is to introduce links back to the parent, and have
these links be made by 'json_object_array_{put,insert}_idx()' and
'json_object_object_add{_ex}()'[1].

[1] For json_object_object_add_ex() we would need to de-constify the second
parameter, as we need to change it's internal state when being added to a
parent object. It may break some applications, but who knows.

But, since this information is needed mostly for JSON patch, another way to
address this, is to also retrieve the parent of an object via JSON pointer
and use json_object_object_del() and json_object_array_del_idx() on the
object's parent.

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
10 months agojson_pointer: convert index to size_t type
Alexandru Ardelean [Sat, 24 Apr 2021 14:06:17 +0000 (17:06 +0300)] 
json_pointer: convert index to size_t type

The index cannot be negative when parsing in is_valid_index(), because we
don't allow the '-' character in a string before we get to the strtol()
function.

So, might as well remove the negative check (for idx) in is_valid_index()
and convert it to size_t. That may allow for higher values for the index
(which can be insane, but some people may want to try it).

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
10 months agotests: test1: add test cases for json_object_array_insert_idx()
Alexandru Ardelean [Tue, 20 Apr 2021 13:07:26 +0000 (16:07 +0300)] 
tests: test1: add test cases for json_object_array_insert_idx()

This change adds a few test cases to test the behavior of the new
json_object_array_insert_idx() function, to make sure it behaves according
to specification in doc-string.

This test uses assert() vs the old method of comparing outputs.
This will cause the test to fail because the outputs won't match, since the
assert() will kick in.

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
10 months agojson_object: introduce json_object_array_insert_idx() API function
Alexandru Ardelean [Fri, 16 Apr 2021 13:12:22 +0000 (16:12 +0300)] 
json_object: introduce json_object_array_insert_idx() API function

The behavior of the json_object_array_put_idx() is that, if a user wants to
insert an element inside a JSON array, the element will be replaced.

For some cases, a user would want to insert an element into the JSON array
and shift the elements to the right.

For indexes that are outside the length of the current array this behaves
like json_object_array_put_idx().
If a user wants to enforce that the JSON array is not expanded, then the
json_object_array_length() function can be used to guard against that.

The main driver for this change is JSON patch, where the 'add' operation in
an array means inserting a value at a certain index and shifting everything
by one.

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
10 months agojson_pointer: fix comments about printf() variants of set/get()
Alexandru Ardelean [Thu, 22 Apr 2021 08:19:07 +0000 (11:19 +0300)] 
json_pointer: fix comments about printf() variants of set/get()

These were wrong. Some details about the json_pointer_setf() &
json_pointer_getf() were added in the json_pointer_set() &
json_pointer_get() doc-strings.

This change removes them.

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
10 months agoIssue #668: add the option to specify "cmake -DUSELOCALE_NEEDS_FREELOCALE=1" to work...
Eric Hawicz [Sun, 30 Jul 2023 17:38:15 +0000 (13:38 -0400)] 
Issue #668: add the option to specify "cmake -DUSELOCALE_NEEDS_FREELOCALE=1" to work around a bug in older versions of FreeBSD (<12.4).

10 months agoIssue #808: turn off -Wshorten-64-to-32 for clang builds (aka iOS builds) to workarou...
Eric Hawicz [Sun, 30 Jul 2023 15:38:01 +0000 (11:38 -0400)] 
Issue #808: turn off -Wshorten-64-to-32 for clang builds (aka iOS builds) to workaround "implicit conversion loses integer precision" warnings.

11 months agoMerge pull request #772 from cosmo-ray/color
Eric Hawicz [Thu, 13 Jul 2023 22:04:48 +0000 (18:04 -0400)] 
Merge pull request #772 from cosmo-ray/color

add JSON_C_TO_STRING_COLOR option

11 months agoadd JSON_C_TO_STRING_COLOR option 772/head
Matthias Gatto [Thu, 2 Jun 2022 15:10:21 +0000 (17:10 +0200)] 
add JSON_C_TO_STRING_COLOR option

This option enable color in json_object_to_json_string_ext.
I've try to made something similar to jq output,
but I've color true/false and null in purple,
as it's what is common color scheme used in programing language in emacs.

also add a '-c' option into json_parser to test it.

note: that I could have done a color() function similar to
what is done with indent(), but as the code is pretty small
I've keep it as it. so if you want  me to use a subfunction
tell me and I'll do it.

Signed-off-by: Matthias Gatto <matthias.gatto@protonmail.com>
11 months agoSkip apps when we're included in someone else's build. Inspired by ssrlive in PR...
Eric Hawicz [Fri, 7 Jul 2023 00:56:49 +0000 (20:56 -0400)] 
Skip apps when we're included in someone else's build.  Inspired by ssrlive in PR #813.

11 months agoFix the -f option to apps/json_parse, add a -F <arg> option to specify arbitrary...
Eric Hawicz [Tue, 4 Jul 2023 16:00:31 +0000 (12:00 -0400)] 
Fix the -f option to apps/json_parse, add a -F <arg> option to specify arbitrary flags to pass to json_object_to_json_string_ext().

11 months agoMerge pull request #759 from c3h2-ctf/truncation
Eric Hawicz [Tue, 4 Jul 2023 15:45:57 +0000 (11:45 -0400)] 
Merge pull request #759 from c3h2-ctf/truncation

json_tokener_parse_ex: handle out of memory errors

11 months agoIssue #688: Only exclude generated doc/* files, keep the CMakeLists.txt, etc... so...
Eric Haszlakiewicz [Sat, 1 Jul 2023 18:02:00 +0000 (18:02 +0000)] 
Issue #688: Only exclude generated doc/* files, keep the CMakeLists.txt, etc... so the nodoc tarball can still be built.

14 months agoStop linking a copy of _json_c_strerror() (strerror_override.c) into the tests.
Eric Haszlakiewicz [Tue, 28 Mar 2023 23:08:39 +0000 (23:08 +0000)] 
Stop linking a copy of _json_c_strerror() (strerror_override.c) into the tests.
That hasn't been needed since since commit 6068d3f, which changed that code to
 check an env var instead ("_JSON_C_STRERROR_ENABLE").
Fixes issue #812, about dup symbols in static builds with clang.

15 months agoMerge pull request #810 from dijonkitchen/patch-1
Eric Hawicz [Fri, 10 Mar 2023 19:54:44 +0000 (14:54 -0500)] 
Merge pull request #810 from dijonkitchen/patch-1

docs: update to Internet Standard reference

15 months agodocs: update to Internet Standard reference 810/head
JC (Jonathan Chen) [Fri, 10 Mar 2023 16:10:29 +0000 (11:10 -0500)] 
docs: update to Internet Standard reference

15 months agoBump up the minimum cmake version to 3.9.
Eric Haszlakiewicz [Thu, 23 Feb 2023 01:01:14 +0000 (01:01 +0000)] 
Bump up the minimum cmake version to 3.9.
This gets us up to a version that supports features we're already using
(i.e. add_compile_options), but stops short of a cmake that requires
c++11, which some OSes still don't support.
Closes issue #774

17 months agoIssue #570: note brief instructions for building on Android.
Eric Haszlakiewicz [Thu, 5 Jan 2023 00:25:09 +0000 (00:25 +0000)] 
Issue #570: note brief instructions for building on Android.

17 months agoMerge pull request #804 from yrashk/cmp-0042
Eric Hawicz [Tue, 27 Dec 2022 14:32:33 +0000 (09:32 -0500)] 
Merge pull request #804 from yrashk/cmp-0042

Problem: cmake 3.25.1 warns about CMP0042 not being set

17 months agoMerge pull request #803 from yrashk/patch-2
Eric Hawicz [Tue, 27 Dec 2022 14:26:30 +0000 (09:26 -0500)] 
Merge pull request #803 from yrashk/patch-2

Problem: confusing error message in snprintf_compat.h

17 months agoMerge pull request #802 from yrashk/patch-1
Eric Hawicz [Tue, 27 Dec 2022 14:25:58 +0000 (09:25 -0500)] 
Merge pull request #802 from yrashk/patch-1

Problem: modern CMake warns about version 2.8

17 months agoProblem: cmake 3.25.1 warns about CMP0042 not being set 804/head
Yurii Rashkovskii [Fri, 23 Dec 2022 22:59:59 +0000 (14:59 -0800)] 
Problem: cmake 3.25.1 warns about CMP0042 not being set

Solution: set it explictly to OLD behavior

17 months agoProblem: confusing error message in snprintf_compat.h 803/head
Yurii Rashkovskii [Fri, 23 Dec 2022 22:35:36 +0000 (14:35 -0800)] 
Problem: confusing error message in snprintf_compat.h

Solution: fix it to reflect what's happening properly

17 months agoProblem: modern CMake warns about version 2.8 802/head
Yurii Rashkovskii [Fri, 23 Dec 2022 22:33:31 +0000 (14:33 -0800)] 
Problem: modern CMake warns about version 2.8

The warning is as follows:

```
Compatibility with CMake < 2.8.12 will be removed from a future version of CMake.
```

Solution: set it at 2.8.12

19 months agoMerge pull request #796 from fedefrancescon/test-add-int-get
Eric Hawicz [Thu, 17 Nov 2022 03:23:11 +0000 (22:23 -0500)] 
Merge pull request #796 from fedefrancescon/test-add-int-get

Added Test for get int functions

19 months agoFixed `test_int_get` expected output 796/head
Federico Francescon [Wed, 16 Nov 2022 00:33:02 +0000 (01:33 +0100)] 
Fixed `test_int_get` expected output

19 months agoAdded basic tests for `json_object_get_int`, `json_object_get_int64`, `json_object_ge...
Federico Francescon [Tue, 15 Nov 2022 23:49:18 +0000 (00:49 +0100)] 
Added basic tests for `json_object_get_int`, `json_object_get_int64`, `json_object_get_uint64`

19 months agoUpdate expected output for test_parse, missed in the previous commit.
Eric Haszlakiewicz [Sun, 30 Oct 2022 19:42:42 +0000 (19:42 +0000)] 
Update expected output for test_parse, missed in the previous commit.

19 months agoExplicitly check for integer overflow/underflow when parsing integers with JSON_TOKEN...
Eric Haszlakiewicz [Sun, 30 Oct 2022 19:29:15 +0000 (19:29 +0000)] 
Explicitly check for integer overflow/underflow when parsing integers with JSON_TOKENER_STRICT.

19 months agoApply same EINVAL handling to json_parse_uint64() as was done for json_parse_int64...
Eric Haszlakiewicz [Sun, 30 Oct 2022 03:25:32 +0000 (03:25 +0000)] 
Apply same EINVAL handling to json_parse_uint64() as was done for json_parse_int64().  Document that overflow/underflow for these functions is not an error, but sets errno=ERANGE.

19 months agoIssue #792 - set errno=EINVAL if parsing the string in json_parse_int64 fails, to...
Eric Haszlakiewicz [Wed, 26 Oct 2022 02:19:38 +0000 (02:19 +0000)] 
Issue #792 - set errno=EINVAL if parsing the string in json_parse_int64 fails, to match the docs for json_object_get_int.

21 months agoMerge pull request #790 from Sarcares/patch-1
Eric Hawicz [Wed, 14 Sep 2022 02:15:48 +0000 (22:15 -0400)] 
Merge pull request #790 from Sarcares/patch-1

Small update to README file

21 months agoSmall update to README file 790/head
Luca Mannella [Mon, 12 Sep 2022 15:29:47 +0000 (17:29 +0200)] 
Small update to README file

it could be necessary to execute make install

22 months agoMerge pull request #784 from rouault/get_time_seed_coverity_scan_silence
Eric Hawicz [Tue, 16 Aug 2022 22:10:06 +0000 (18:10 -0400)] 
Merge pull request #784 from rouault/get_time_seed_coverity_scan_silence

get_time_seed(): silence warning emitted by Coverity Scan static analyzer

22 months agoget_time_seed(): silence warning emitted by Coverity Scan static analyzer 784/head
Even Rouault [Tue, 16 Aug 2022 09:11:55 +0000 (11:11 +0200)] 
get_time_seed(): silence warning emitted by Coverity Scan static analyzer

It warns about the return of time() being truncated to 32 bit, which is
not an issue here.
(this warning was emitted because of the https://github.com/OSGeo/gdal
project embedding a copy of libjson-c and running Coverity Scan
analysis)

22 months agoMerge pull request #783 from kraj/master
Eric Hawicz [Sun, 14 Aug 2022 12:19:19 +0000 (08:19 -0400)] 
Merge pull request #783 from kraj/master

Fix build with clang-15+

22 months agojson_pointer.c: Move idx_val declaration to top of function 783/head
Khem Raj [Sun, 14 Aug 2022 07:46:28 +0000 (00:46 -0700)] 
json_pointer.c: Move idx_val declaration to top of function

This helps compiling with MS compiler, error seems to be
due to defining a variable within the body of the function
its allowed in c99 but not in c89. This should fix build with
MSVC 16.0.40219.1 compiler from Visual Studio 14 2015

Signed-off-by: Khem Raj <raj.khem@gmail.com>
22 months agojson_inttypes.h: Define ssize_t on windows platforms
Khem Raj [Sun, 14 Aug 2022 04:45:11 +0000 (21:45 -0700)] 
json_inttypes.h: Define ssize_t on windows platforms

Signed-off-by: Khem Raj <raj.khem@gmail.com>
22 months agoFix build with clang-15+
Khem Raj [Sun, 14 Aug 2022 03:37:03 +0000 (20:37 -0700)] 
Fix build with clang-15+

Fixes
json_util.c:63:35: error: a function declaration without a prototype is deprecated in all versions of C [-We
rror,-Wstrict-prototypes]
const char *json_util_get_last_err()
                                  ^
                                   void

Signed-off-by: Khem Raj <raj.khem@gmail.com>
22 months agoMerge pull request #782 from DimitriPapadopoulos/codespell
Eric Hawicz [Sat, 13 Aug 2022 13:43:50 +0000 (09:43 -0400)] 
Merge pull request #782 from DimitriPapadopoulos/codespell

Fix typos found by codespell

22 months agoFix typos found by codespell 782/head
Dimitri Papadopoulos [Sat, 13 Aug 2022 12:47:40 +0000 (15:47 +0300)] 
Fix typos found by codespell

Do not fix typos from past commits found in release notes.

22 months agoApply some of the fixes from PR #740, although by using size_t instead of castings.
Eric Haszlakiewicz [Sun, 31 Jul 2022 19:26:12 +0000 (19:26 +0000)] 
Apply some of the fixes from PR #740, although by using size_t instead of castings.

22 months agoMerge pull request #757 from c3h2-ctf/big
Eric Hawicz [Sun, 31 Jul 2022 18:27:32 +0000 (14:27 -0400)] 
Merge pull request #757 from c3h2-ctf/big

json_object_from_fd_ex: fail if file is too large

22 months agoIssue #705: disable locale handling when building for a uClibc system because its...
Eric Haszlakiewicz [Sat, 30 Jul 2022 20:27:35 +0000 (20:27 +0000)] 
Issue #705: disable locale handling when building for a uClibc system because its duplocale() function (intentionally) crashes.

22 months agoWhen serializing with JSON_C_TO_STRING_PRETTY set, keep the opening and closing curly...
Eric Haszlakiewicz [Sat, 30 Jul 2022 19:27:14 +0000 (19:27 +0000)] 
When serializing with JSON_C_TO_STRING_PRETTY set, keep the opening and closing curly or square braces on same line for empty objects or arrays.  Issue #778.

22 months agoUpdate Travis links to point at travis-ci.com instead of travis-ci.org
Eric Haszlakiewicz [Tue, 26 Jul 2022 23:47:58 +0000 (23:47 +0000)] 
Update Travis links to point at travis-ci.com instead of travis-ci.org

22 months agoEntirely drop mode bits from open(O_RDONLY) to avoid warnings on certain platforms...
Eric Haszlakiewicz [Tue, 26 Jul 2022 23:43:30 +0000 (23:43 +0000)] 
Entirely drop mode bits from open(O_RDONLY) to avoid warnings on certain platforms.  Fixes issue #779.

22 months agoTrim a few travis builds, update others to more recent toolchains.
Eric Haszlakiewicz [Sun, 24 Jul 2022 20:37:14 +0000 (20:37 +0000)] 
Trim a few travis builds, update others to more recent toolchains.

22 months agoFix the expected output for test_set_serializer.
Eric Haszlakiewicz [Sun, 24 Jul 2022 19:00:27 +0000 (19:00 +0000)] 
Fix the expected output for test_set_serializer.

22 months agoAdd test to check for the memory leak mentioned in issue #781
Eric Haszlakiewicz [Sun, 24 Jul 2022 18:59:26 +0000 (18:59 +0000)] 
Add test to check for the memory leak mentioned in issue #781

22 months agoMerge pull request #781 from dddaniel/master
Eric Hawicz [Sun, 24 Jul 2022 18:15:42 +0000 (14:15 -0400)] 
Merge pull request #781 from dddaniel/master

Fix memory leak with emtpy strings in json_object_set_string

22 months agoFix memory leak with emtpy strings in json_object_set_string 781/head
Daniel Danzberger [Sun, 24 Jul 2022 16:46:03 +0000 (18:46 +0200)] 
Fix memory leak with emtpy strings in json_object_set_string

When a json string object is updated with a bigger string, a new
malloc'ed buffer is used to store the new string and it's size is made
negative to indicate that an external buffer is in use.

When that same json string object get's updated again with an empty
stirng (size = 0), the new external malloc'ed buffer is still used.
But the fact that the new size value is not negative removes the
indicator that the externally malloc'ed buffer is used.

This becomes a problem when the object get's updated again with any
other string, because a new buffer will be malloced and linked to the
object while to old one won't be free'd.

This causes a memory leak when updating a json string with
json_object_set_stirng() which has previously been updated
with an empty string.

Example:
--
obj = json_object_new_string("data");
json_object_set_string(obj, "more data");
json_object_set_string(obj, "");
json_object_set_string(obj, "other data"); /* leaks */
--

This commit fixes the issue by free'ing the external buffer when an
empty string is set and use the internal one again.

Signed-off-by: Daniel Danzberger <daniel@dd-wrt.com>
23 months agoFix issue #775 - use a loop instead of list(TRANSFORM ...) to support cmake < 3.12.
Eric Haszlakiewicz [Mon, 27 Jun 2022 02:15:24 +0000 (02:15 +0000)] 
Fix issue #775 - use a loop instead of list(TRANSFORM ...) to support cmake < 3.12.

23 months agoMerge pull request #776 from stoeckmann/typo
Eric Hawicz [Wed, 22 Jun 2022 01:39:00 +0000 (21:39 -0400)] 
Merge pull request #776 from stoeckmann/typo

Fix typo

23 months agoFix typo 776/head
Tobias Stoeckmann [Tue, 21 Jun 2022 12:39:01 +0000 (14:39 +0200)] 
Fix typo

2 years agoFix #771/#768 by marking usage() as "noreturn" instead of using "FALLTHRU" in the...
Eric Haszlakiewicz [Mon, 13 Jun 2022 01:02:53 +0000 (01:02 +0000)] 
Fix #771/#768 by marking usage() as "noreturn" instead of using "FALLTHRU" in the case statement where it'd called.

2 years agoMerge pull request #769 from An7ar35/issue-768
Eric Hawicz [Sat, 4 Jun 2022 03:14:16 +0000 (23:14 -0400)] 
Merge pull request #769 from An7ar35/issue-768

Issue #768

2 years agomissing 'FALLTHRU' added to sort out error messages when using "-Werror=implicit... 769/head
An7ar35 [Wed, 1 Jun 2022 10:36:33 +0000 (12:36 +0200)] 
missing 'FALLTHRU' added to sort out error messages when using "-Werror=implicit-fallthrough" flag

2 years agoUnset NDEBUG so assert() is enabled in all tests. One more fix there when building...
Eric Haszlakiewicz [Mon, 30 May 2022 15:39:54 +0000 (15:39 +0000)] 
Unset NDEBUG so assert() is enabled in all tests.  One more fix there when building with -DCMAKE_BUILD_TYPE=release.

2 years agoSpecify dependent libraries, including -lbsd, in a more consistent way so linking...
Eric Haszlakiewicz [Mon, 30 May 2022 15:30:11 +0000 (15:30 +0000)] 
Specify dependent libraries, including -lbsd, in a more consistent way so linking against a static json-c works better.  Related issue #766
Use target_link_libraries, plus fill in Libs.private in json-c.pc so pkg-config --static --libs works appropriately.
Also, only link against libbsd when arc4random is actually found there.

2 years agoInclude the tests and apps directories at the _end_, since order in the
Eric Haszlakiewicz [Mon, 30 May 2022 14:33:16 +0000 (14:33 +0000)] 
Include the tests and apps directories at the _end_, since order in the
cmake rules matters, and fix compile warnings now that we're building
those sources with all the regular flags.

2 years agoAdd --disable-static and --disable-dynamic options to the cmake-configure script.
Eric Haszlakiewicz [Mon, 30 May 2022 14:31:08 +0000 (14:31 +0000)] 
Add --disable-static and --disable-dynamic options to the cmake-configure script.

2 years agoNote the DSIABLE_JSON_POINTER and DISABLE_EXTRA_LIBS build options on the README
Eric Haszlakiewicz [Thu, 14 Apr 2022 12:57:43 +0000 (12:57 +0000)] 
Note the DSIABLE_JSON_POINTER and DISABLE_EXTRA_LIBS build options on the README

2 years agoAdd a "Getting Help" section to the README.
Eric Haszlakiewicz [Thu, 14 Apr 2022 12:55:32 +0000 (12:55 +0000)] 
Add a "Getting Help" section to the README.

2 years agoUpdate the master branch to version 16.99
Eric Haszlakiewicz [Thu, 14 Apr 2022 12:29:39 +0000 (12:29 +0000)] 
Update the master branch to version 16.99

2 years agoClarify how to set the uploaded release tarballs to be publically readable.
Eric Haszlakiewicz [Thu, 14 Apr 2022 12:17:59 +0000 (12:17 +0000)] 
Clarify how to set the uploaded release tarballs to be publically readable.

2 years agoUpdate the ChangeLog with recent changes, in preparation for a 0.16 release.
Eric Haszlakiewicz [Thu, 14 Apr 2022 00:21:13 +0000 (00:21 +0000)] 
Update the ChangeLog with recent changes, in preparation for a 0.16 release.
Add a list of issues closed for this release.

2 years agoAdd new authors since the 0.15 release, tweak instructions for how to update that...
Eric Haszlakiewicz [Wed, 13 Apr 2022 23:16:34 +0000 (23:16 +0000)] 
Add new authors since the 0.15 release, tweak instructions for how to update that list.

2 years agoMerge pull request #765 from jvoisin/patch-1
Eric Hawicz [Wed, 13 Apr 2022 18:28:51 +0000 (14:28 -0400)] 
Merge pull request #765 from jvoisin/patch-1

Improve a bit the coverage of the fuzzer

2 years agoImprove a bit the coverage of the fuzzer 765/head
Julien Voisin [Wed, 13 Apr 2022 13:42:46 +0000 (15:42 +0200)] 
Improve a bit the coverage of the fuzzer