]> granicus.if.org Git - json-c/log
json-c
3 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.

3 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.

3 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.

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

3 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).

3 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.

3 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
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
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.
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.
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
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
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.
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
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.
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
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
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 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
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
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
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
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
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.

4 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.

4 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().

4 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.

4 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.

4 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().

4 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

4 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.

4 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

4 years agobuild: Add symbol versions to all exported symbols
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>
4 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.

4 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.

4 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().

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

4 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.

4 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().

4 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

4 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.

4 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().

4 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

4 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.

4 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.

4 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).

4 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.

4 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.

4 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.

4 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

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

4 years agoMerge pull request #634 from micahsnyder/json-c-fPIC
Eric Hawicz [Sun, 14 Jun 2020 21:56:35 +0000 (17:56 -0400)]
Merge pull request #634 from micahsnyder/json-c-fPIC

Issue #508: `-fPIC` to link libjson-c.a with libs

4 years agoIssue #508: `-fPIC` to link libjson-c.a with libs
Micah Snyder [Sun, 14 Jun 2020 16:01:48 +0000 (12:01 -0400)]
Issue #508: `-fPIC` to link libjson-c.a with libs

json-c has symbol collisions with other popular C JSON libraries.
To prevent random crashes in downstream applications that may use a
library which depends on json-c, the solution is to statically link
libjson-c.a into those libraries.

`-fPIC`/`-fPIE` is required when building a `.a` so it can be linked
into a `.so`.

4 years agoInclude unistd.h to fix the build on OSX
Eric Haszlakiewicz [Sun, 14 Jun 2020 03:11:44 +0000 (03:11 +0000)]
Include unistd.h to fix the build on OSX

4 years agoDrop the _delete field from struct json_object and call the type-specific delete...
Eric Haszlakiewicz [Sat, 13 Jun 2020 18:34:35 +0000 (18:34 +0000)]
Drop the _delete field from struct json_object and call the type-specific delete functions directly from json_object_put.  (Thanks @dota17 for the suggestion in PR #632!)

4 years agoDrop the useless "char data[1]" from struct json_object. Fix a typo in a comment.
Eric Haszlakiewicz [Sat, 13 Jun 2020 18:25:32 +0000 (18:25 +0000)]
Drop the useless "char data[1]" from struct json_object.  Fix a typo in a comment.

4 years agofix issue 616: support the surrogate pair in split file.
dota17 [Tue, 2 Jun 2020 11:17:42 +0000 (19:17 +0800)]
fix issue 616: support the surrogate pair in split file.

4 years agoEliminate unnecessary cast that was added to test_double_serializer.
Eric Haszlakiewicz [Sun, 7 Jun 2020 18:50:10 +0000 (18:50 +0000)]
Eliminate unnecessary cast that was added to test_double_serializer.

4 years agoSummarize the changes from the json_object-split branch in the ChangeLog.
Eric Haszlakiewicz [Sun, 7 Jun 2020 18:45:17 +0000 (18:45 +0000)]
Summarize the changes from the json_object-split branch in the ChangeLog.

4 years agoMove the ssize_t typedef from json_inttypes.h to json_object_private.h so as not...
Eric Haszlakiewicz [Sun, 7 Jun 2020 18:29:56 +0000 (18:29 +0000)]
Move the ssize_t typedef from json_inttypes.h to json_object_private.h so as not to affect publically exposed symbols.

4 years agoThe split of json_object into type-specific sub-structures is now functionally complete.
Eric Haszlakiewicz [Sun, 7 Jun 2020 03:30:39 +0000 (03:30 +0000)]
The split of json_object into type-specific sub-structures is now functionally complete.
Remove all of the temporary defines, structures, old compat fuctions, extra fields, etc... that were needed during the conversion to a split set of json_object_* structures.

4 years agoMore fixes for old MSVC builds.
Eric Haszlakiewicz [Sun, 7 Jun 2020 15:25:59 +0000 (15:25 +0000)]
More fixes for old MSVC builds.

4 years agoFix typo in previous commit to check for SSIZE_T on MSVC.
Eric Haszlakiewicz [Sun, 7 Jun 2020 15:19:29 +0000 (15:19 +0000)]
Fix typo in previous commit to check for SSIZE_T on MSVC.

4 years agoChange CMakeLists.txt to look for SSIZE_T on MSVC too.
Eric Haszlakiewicz [Sun, 7 Jun 2020 03:36:59 +0000 (03:36 +0000)]
Change CMakeLists.txt to look for SSIZE_T on MSVC too.

4 years agoOn MSVC, add a ssize_t typedef using SSIZE_T from BaseTsd.h
Eric Haszlakiewicz [Sun, 7 Jun 2020 03:27:13 +0000 (03:27 +0000)]
On MSVC, add a ssize_t typedef using SSIZE_T from BaseTsd.h

4 years agoKick json_type_string out of struct json_object.
Eric Haszlakiewicz [Sun, 7 Jun 2020 02:42:58 +0000 (02:42 +0000)]
Kick json_type_string out of struct json_object.
The default is now that string data is stored inline at the end of json_object, though to allow for json_object_set_string() to set a _longer_ string, we still need to allow for the possibility of a separate char * pointer.
All json types have been split out now, next step it cleanup.

4 years agoMerge pull request #628 from clamwin/compat-fixes-master
Eric Hawicz [Thu, 4 Jun 2020 03:53:46 +0000 (23:53 -0400)]
Merge pull request #628 from clamwin/compat-fixes-master

get_cryptgenrandom_seed: compat with old windows + fallback

4 years agoget_cryptgenrandom_seed: compat with old windows + fallback
Gianluigi Tiesi [Mon, 1 Jun 2020 18:49:08 +0000 (20:49 +0200)]
get_cryptgenrandom_seed: compat with old windows + fallback

4 years agoApply the fix from @pointbre in issue #626 to skip "inline" on AIX, but invert the...
Eric Haszlakiewicz [Sun, 31 May 2020 03:22:14 +0000 (03:22 +0000)]
Apply the fix from @pointbre in issue #626 to skip "inline" on AIX, but invert the test to make it a little easier to understand.

4 years agoIssue #626: Restore compatibility with cmake 2.8 by adjusting quoting and explicitly...
Eric Haszlakiewicz [Sat, 30 May 2020 19:36:54 +0000 (19:36 +0000)]
Issue #626: Restore compatibility with cmake 2.8 by adjusting quoting and explicitly defining the PROJECT_VERSION* variables.

4 years agoKick json_type_int and json_type_double out of struct json_object.
Eric Haszlakiewicz [Tue, 26 May 2020 02:31:35 +0000 (02:31 +0000)]
Kick json_type_int and json_type_double out of struct json_object.
Clean up the code in json_object_new_* a bit by dropping unnecesary json_object_base variables.

4 years agoDeclare variables earlier, to appease Visual Studio 2010.
Eric Haszlakiewicz [Mon, 25 May 2020 04:10:11 +0000 (04:10 +0000)]
Declare variables earlier, to appease Visual Studio 2010.

4 years agoKick json_type_boolean out of struct json_object.
Eric Haszlakiewicz [Mon, 25 May 2020 04:04:02 +0000 (04:04 +0000)]
Kick json_type_boolean out of struct json_object.

4 years agoAdd some backwards compat for Visual Studio 2013.
Eric Haszlakiewicz [Mon, 25 May 2020 03:52:36 +0000 (03:52 +0000)]
Add some backwards compat for Visual Studio 2013.