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

2 years 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.

2 years 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.

2 years 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.

2 years 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

2 years agoSmall update to README file
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

2 years 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

2 years agoget_time_seed(): silence warning emitted by Coverity Scan static analyzer
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)

2 years 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+

2 years agojson_pointer.c: Move idx_val declaration to top of function
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>
2 years 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>
2 years 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>
2 years 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

2 years agoFix typos found by codespell
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.

2 years 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.

2 years 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

2 years 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.

2 years 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.

2 years 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

2 years 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.

2 years 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.

2 years 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.

2 years 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

2 years 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

2 years agoFix memory leak with emtpy strings in json_object_set_string
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>
2 years 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.

2 years 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

2 years agoFix typo
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...
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
Julien Voisin [Wed, 13 Apr 2022 13:42:46 +0000 (15:42 +0200)]
Improve a bit the coverage of the fuzzer

2 years agoFix issue #764: adjust test_util_file to match new output (changed in 6e53347)
Eric Haszlakiewicz [Fri, 8 Apr 2022 22:58:24 +0000 (22:58 +0000)]
Fix issue #764: adjust test_util_file to match new output (changed in 6e53347)

2 years agoMerge pull request #758 from c3h2-ctf/context
Eric Hawicz [Mon, 4 Apr 2022 22:01:39 +0000 (18:01 -0400)]
Merge pull request #758 from c3h2-ctf/context

Preserve context if out of memory

2 years agoUpdate issue templates
Eric Hawicz [Mon, 4 Apr 2022 21:10:31 +0000 (17:10 -0400)]
Update issue templates

2 years agoPreserve context if out of memory
Tobias Stoeckmann [Sun, 20 Mar 2022 12:22:46 +0000 (13:22 +0100)]
Preserve context if out of memory

If memory allocation fails in json_c_set_serialization_double_format or
json_object_copy_serializer_data then return with an error value and
preserve previous values without overriding them with NULL.

2 years agoRemove single quote from #error line. Fixes issue #761
Eric Haszlakiewicz [Fri, 25 Mar 2022 01:11:52 +0000 (01:11 +0000)]
Remove single quote from #error line.  Fixes issue #761

2 years agoMerge pull request #760 from BonsaiYi/error
Eric Hawicz [Wed, 23 Mar 2022 04:14:36 +0000 (00:14 -0400)]
Merge pull request #760 from BonsaiYi/error

Code style: removed unneeded double-quotes

2 years agoCode style removed unneeded double-quotes
BonsaY [Mon, 21 Mar 2022 20:10:45 +0000 (21:10 +0100)]
Code style removed unneeded double-quotes

this way, it complies with the other #error usages

2 years agojson_object_from_fd_ex: fail if file is too large
Tobias Stoeckmann [Sun, 20 Mar 2022 12:17:37 +0000 (13:17 +0100)]
json_object_from_fd_ex: fail if file is too large

If the input file is too large to fit into a printbuf then return an
error value instead of silently truncating the parsed content.

This introduces errno handling into printbuf to distinguish between an
input file being too large and running out of memory.

2 years agoMerge pull request #755 from c3h2-ctf/error
Eric Hawicz [Sat, 19 Mar 2022 14:05:48 +0000 (10:05 -0400)]
Merge pull request #755 from c3h2-ctf/error

Fix error messages

2 years agoMerge pull request #754 from c3h2-ctf/doc
Eric Hawicz [Sat, 19 Mar 2022 14:04:58 +0000 (10:04 -0400)]
Merge pull request #754 from c3h2-ctf/doc

Minor improvements to documentation

2 years agoFix error messages
Tobias Stoeckmann [Sat, 19 Mar 2022 09:59:43 +0000 (10:59 +0100)]
Fix error messages

Error messages did not reflect actual function names.

2 years agoFix typos in comments
Tobias Stoeckmann [Sat, 19 Mar 2022 09:39:10 +0000 (10:39 +0100)]
Fix typos in comments

Spotted during code reviews.

2 years agoAdjusted URLs
Tobias Stoeckmann [Sat, 19 Mar 2022 09:34:55 +0000 (10:34 +0100)]
Adjusted URLs

Most of these sites support HTTPS (some forward to HTTPS when accessing
the HTTP versions). Use HTTPS directly if supported.

Some URLs led to 404 error pages. Adjusted the links to point to
new locations.

I did not adjust the Microsoft HTML Help Workshop link because it seems
that this software is not available anymore. Instead of removing the
link entirely I kept it there in case it helps someone to find the
software on archived websites.

2 years agoMerge pull request #748 from c3h2-ctf/printbuf
Eric Hawicz [Mon, 7 Mar 2022 05:06:57 +0000 (00:06 -0500)]
Merge pull request #748 from c3h2-ctf/printbuf

sprintbuf(): test for all vsnprintf error values

2 years agoMerge pull request #752 from c3h2-ctf/typos
Eric Hawicz [Mon, 7 Mar 2022 04:33:42 +0000 (23:33 -0500)]
Merge pull request #752 from c3h2-ctf/typos

Fix typos

2 years agoFix typos
Tobias Stoeckmann [Sun, 6 Mar 2022 15:07:36 +0000 (16:07 +0100)]
Fix typos

Mostly found with codespell and during code review.

2 years agosprintbuf(): test for all vsnprintf error values
Tobias Stoeckmann [Sun, 27 Feb 2022 20:45:28 +0000 (21:45 +0100)]
sprintbuf(): test for all vsnprintf error values

The POSIX specification states that vsnprintf returns "a negative value"
in case of error, but the code checks explicitly only for -1.

2 years agoMerge pull request #749 from c3h2-ctf/sprintbuf
Eric Hawicz [Fri, 4 Mar 2022 02:32:09 +0000 (21:32 -0500)]
Merge pull request #749 from c3h2-ctf/sprintbuf

sprintbuf(): handle printbuf_memappend errors

2 years agoMerge pull request #750 from c3h2-ctf/clearmem
Eric Hawicz [Fri, 4 Mar 2022 02:29:27 +0000 (21:29 -0500)]
Merge pull request #750 from c3h2-ctf/clearmem

printbuf_memset(): set gaps to zero

2 years agoMerge pull request #751 from c3h2-ctf/arguments
Eric Hawicz [Fri, 4 Mar 2022 02:26:22 +0000 (21:26 -0500)]
Merge pull request #751 from c3h2-ctf/arguments

printbuf: do not allow invalid arguments

2 years agosprintbuf(): handle printbuf_memappend errors
Tobias Stoeckmann [Thu, 3 Mar 2022 20:24:27 +0000 (21:24 +0100)]
sprintbuf(): handle printbuf_memappend errors

If errors occur in printbuf_memappend, then these errors should be
propagated through sprintbuf to indicate the error to the user.

Proof of Concept:
```
 #include <err.h>
 #include <limits.h>
 #include <stdio.h>

 #include "json.h"

 int
 main(void) {
  struct printbuf *pb;
  if ((pb = printbuf_new()) == NULL)
   err(1, "printbuf_new");
  if (printbuf_memset(pb, INT_MAX - 9, 'a', 1) < 0)
   errx(1, "printbuf_memset");
  printf("length: %d\n", printbuf_length(pb));
  printf("sprintbuf: %d\n", sprintbuf(pb, "string too long"));
  printf("length: %d\n", printbuf_length(pb));
  printbuf_free(pb);
  return 0;
 }
```

You can see that sprintbuf does not return an error but length is still
the same, i.e. the string "string too long" has not been appended.

I would like to add this as a unit test but it really depends on the
operating system if printbuf_memset() would fail if not enough memory is
available or not.

2 years agoprintbuf_memset(): set gaps to zero
Tobias Stoeckmann [Thu, 3 Mar 2022 20:18:53 +0000 (21:18 +0100)]
printbuf_memset(): set gaps to zero

It is possible to have a printbuf with "gaps", i.e. areas within the
print buffer which have not been initialized by using printbuf_memset.

Always clear memory in such cases.

Example:
```
struct printbuf *pb = printbuf_new();
printbuf_memset(pb, 10, 'a', 2);
```
In this case pb->buf[0] is '\0' but pb->buf[1] up to pb->buf[9] are
not set. The length would be 12 due to successful printbuf_memset.

2 years agoprintbuf: do not allow invalid arguments
Tobias Stoeckmann [Thu, 3 Mar 2022 20:15:19 +0000 (21:15 +0100)]
printbuf: do not allow invalid arguments

If invalid arguments are passed to printbuf functions return -1 to
protect printbuf internals.

2 years agoMerge pull request #745 from c3h2-ctf/vasprintf
Eric Hawicz [Sun, 27 Feb 2022 13:34:21 +0000 (08:34 -0500)]
Merge pull request #745 from c3h2-ctf/vasprintf

vasprintf(): avoid out of memory accesses

2 years agoMerge pull request #746 from rouault/typo_fixes
Eric Hawicz [Sun, 27 Feb 2022 04:45:15 +0000 (23:45 -0500)]
Merge pull request #746 from rouault/typo_fixes

Fix typos in code comments and ChangeLog

2 years agoFix typos in code comments and ChangeLog
Even Rouault [Thu, 24 Feb 2022 23:14:47 +0000 (00:14 +0100)]
Fix typos in code comments and ChangeLog

2 years agovasprintf(): avoid out of memory accesses
Tobias Stoeckmann [Thu, 24 Feb 2022 20:35:44 +0000 (21:35 +0100)]
vasprintf(): avoid out of memory accesses

Systems without vasprintf fall back to implementation in header file
vasprintf_compat.h. This version could run into heap overflow issues
with very long arguments or formats provoking a lot of output.

The vsnprintf function returns a negative value if more than INT_MAX
characters would be written since its int return type could not
handle this (and %n couldn't handle it either).

Before testing for a possible error value the additional char for
\0 is already added. A -1 error code would not be detected.

Increment only after implicitly casting to an unsigned value to avoid
signed integer overflow if INT_MAX has been returned.

Use va_copy to duplicate the original ap argument for multiple uses
on non-WIN32 systems. At least with glibc the test suite would fail
because the arguments are not reset after leaving the vsnprintf call.

Removed support for apparently very old glibc versions which do not
comply with vsnprintf standard descriptions. It breaks support for
modern ones which are not forced to return -1 in case of error. The
standard specifies merely "a negative value".

How to reproduce:

- Use a system without vasprintf
- Alternatively remove -D_GNU_SOURCE from CMakeLists.txt
- Compile and run:

  #include "json.h"
  int main(void) {
    struct printbuf *pb = printbuf_new();
    sprintbuf(pb, "prefix %2147483647s", "*");
    printbuf_free(pb);
    return 0;
  }

2 years agoMerge pull request #739 from rouault/avoid_unsigned_integer_overflow
Eric Hawicz [Sat, 19 Feb 2022 01:21:18 +0000 (20:21 -0500)]
Merge pull request #739 from rouault/avoid_unsigned_integer_overflow

json_escape_str(): avoid harmless unsigned integer overflow

2 years agoMerge pull request #741 from rouault/json_type_to_name_formatter
Eric Hawicz [Sat, 19 Feb 2022 01:08:31 +0000 (20:08 -0500)]
Merge pull request #741 from rouault/json_type_to_name_formatter

json_type_to_name(): use correct printf() formatter

2 years agoMerge pull request #742 from rouault/json_object_copy_serializer_data_add_assertion
Eric Hawicz [Sat, 19 Feb 2022 01:08:02 +0000 (20:08 -0500)]
Merge pull request #742 from rouault/json_object_copy_serializer_data_add_assertion

json_object_copy_serializer_data(): add assertion

2 years agoMerge pull request #744 from Kizuna-Meraki/close-random
Eric Hawicz [Sat, 19 Feb 2022 01:07:33 +0000 (20:07 -0500)]
Merge pull request #744 from Kizuna-Meraki/close-random

Close file on error path.

2 years agoClose file on error path.
Kizuna-Meraki [Thu, 17 Feb 2022 20:27:01 +0000 (21:27 +0100)]
Close file on error path.

The file was only be closed when there was no error and
was being left open when there was an error. By moving
the close(fd) statement out of the if-clause, the file
can be close regardless if there is an error or not.
After the file is closed, it can be checked for errors.

2 years agojson_type_to_name(): use correct printf() formatter
Even Rouault [Sun, 16 Jan 2022 19:48:27 +0000 (20:48 +0100)]
json_type_to_name(): use correct printf() formatter

Was detected by Coverity Scan when analyzing GDAL's code base which has
a copy of json-c

2 years agojson_object_copy_serializer_data(): add assertion
Even Rouault [Sun, 16 Jan 2022 19:50:56 +0000 (20:50 +0100)]
json_object_copy_serializer_data(): add assertion

This makes Coverity Scan happier since it believes that the initial
check ``if (!src->_userdata && !src->_user_delete)`` could mean that
src->_user_data may be nullptr.

2 years agojson_escape_str(): avoid harmless unsigned integer overflow
Even Rouault [Wed, 12 Jan 2022 22:43:03 +0000 (23:43 +0100)]
json_escape_str(): avoid harmless unsigned integer overflow

Current behaviour is perfectly valid, since wrap-over upon overflow is
well defined behaviour for unsigned types, but it is nevertheless nice to be
able to build with -fsanitize=undefined,unsigned-integer-overflow

There is no significant effect on the generated assembly as can be seen
on the diff of objdump -d output on a optimized build (the compiler
just decided to switch the order of a comparison):

@@ -135,8 +135,8 @@
  1d0: 0f 84 70 ff ff ff     je     146 <json_escape_str+0x146>
  1d6: 4c 3b 24 24           cmp    (%rsp),%r12
  1da: 0f 85 2d ff ff ff     jne    10d <json_escape_str+0x10d>
- 1e0: 49 39 f4              cmp    %rsi,%r12
- 1e3: 0f 87 b7 00 00 00     ja     2a0 <json_escape_str+0x2a0>
+ 1e0: 4c 39 e6              cmp    %r12,%rsi
+ 1e3: 0f 82 b7 00 00 00     jb     2a0 <json_escape_str+0x2a0>
  1e9: 48 8b 44 24 18        mov    0x18(%rsp),%rax
  1ee: 64 48 33 04 25 28 00  xor    %fs:0x28,%rax
  1f5: 00 00

2 years agoMerge pull request #737 from tniessen/patch-1
Eric Hawicz [Wed, 12 Jan 2022 02:25:38 +0000 (21:25 -0500)]
Merge pull request #737 from tniessen/patch-1

Fix typo in README

2 years agoFix typo in README
Tobias Nießen [Sun, 9 Jan 2022 23:12:25 +0000 (00:12 +0100)]
Fix typo in README

3 years agoCause the cmake include dirs to also have ${CMAKE_INSTALL_INCLUDEDIR}/json-c, so...
Eric Haszlakiewicz [Wed, 22 Dec 2021 02:52:37 +0000 (02:52 +0000)]
Cause the cmake include dirs to also have ${CMAKE_INSTALL_INCLUDEDIR}/json-c, so downstream packages that use cmake to link against json-c can choose whether to include headers as just e.g. #include <json_object.h>, if they care to do so.
Update the README to better explain this, and make a few other tweaks.

3 years agoAdd linkhash accessor functions (lh_table_head(), lh_entry_next(), etc...) to pave...
Eric Haszlakiewicz [Tue, 30 Nov 2021 03:27:55 +0000 (03:27 +0000)]
Add linkhash accessor functions (lh_table_head(), lh_entry_next(), etc...) to pave the way for making the lh_table and lh_entry structure opaque in the future.
Update the docs to mark all members of those structures deprecated, and
 suggest what to use instead.

3 years agoDrop the REFCOUNT_DEBUG code, it hasn't been used in ages.
Eric Haszlakiewicz [Tue, 30 Nov 2021 03:08:02 +0000 (03:08 +0000)]
Drop the REFCOUNT_DEBUG code, it hasn't been used in ages.

3 years agoMerge pull request #734 from json-c/newer-appveyor
Eric Hawicz [Mon, 29 Nov 2021 18:40:41 +0000 (13:40 -0500)]
Merge pull request #734 from json-c/newer-appveyor

Newer appveyor config for VS2022 etc...
Update the appveyor config to specify "image" instead of just "os", and build for VS2017, VS2019 and VS2022.

3 years agoPut the most recent image first in appveyor builds. newer-appveyor
Eric Haszlakiewicz [Mon, 29 Nov 2021 18:21:05 +0000 (18:21 +0000)]
Put the most recent image first in appveyor builds.

3 years agoSkip most "Release" builds. s/b_config/CONFIGURATION/ to fix artifact creation.
Eric Haszlakiewicz [Mon, 29 Nov 2021 18:18:48 +0000 (18:18 +0000)]
Skip most "Release" builds.  s/b_config/CONFIGURATION/ to fix artifact creation.

3 years agoThere doesn't seem to be a way to extend the appveyor build matrix for just one image...
Eric Haszlakiewicz [Sat, 27 Nov 2021 02:55:29 +0000 (02:55 +0000)]
There doesn't seem to be a way to extend the appveyor build matrix for just one image, so instead list a whole bunch of excluded builds.

3 years agoUse the newer appveyor images to build for VS2017 and VS2019. Trim the number of...
Eric Haszlakiewicz [Sat, 27 Nov 2021 02:29:26 +0000 (02:29 +0000)]
Use the newer appveyor images to build for VS2017 and VS2019.  Trim the number of builds we do.

3 years agoNote the need to also set CTEST_OUTPUT_ON_FAILURE to get test output
Eric Haszlakiewicz [Fri, 26 Nov 2021 22:49:06 +0000 (22:49 +0000)]
Note the need to also set CTEST_OUTPUT_ON_FAILURE to get test output

3 years agoMerge pull request #732 from DiracResearch/fix/static_include_dirs
Eric Hawicz [Fri, 12 Nov 2021 04:52:43 +0000 (23:52 -0500)]
Merge pull request #732 from DiracResearch/fix/static_include_dirs

Fix/static include dirs

3 years agoFix uninitialized value error for clang-8 msan
Robert Bielik [Thu, 11 Nov 2021 09:23:05 +0000 (10:23 +0100)]
Fix uninitialized value error for clang-8 msan

3 years agoFix for clang ub sanitizer
Robert Bielik [Thu, 11 Nov 2021 08:35:31 +0000 (09:35 +0100)]
Fix for clang ub sanitizer

3 years agoAdd target include dirs for static library as well
Robert Bielik [Wed, 10 Nov 2021 15:04:01 +0000 (16:04 +0100)]
Add target include dirs for static library as well

3 years agoMerge pull request #727 from jobol/propo2
Eric Hawicz [Fri, 22 Oct 2021 23:06:11 +0000 (19:06 -0400)]
Merge pull request #727 from jobol/propo2

Really use prefix JSON_C_OBJECT_ADD_

3 years agoReally use prefix JSON_C_OBJECT_ADD_*
José Bollo [Tue, 12 Oct 2021 12:42:12 +0000 (14:42 +0200)]
Really use prefix JSON_C_OBJECT_ADD_*

This change introduces JSON_C_OBJECT_ADD_CONSTANT_KEY
as a replacement of JSON_C_OBJECT_KEY_IS_CONSTANT.

The description of json_object_object_add_ex tells to
look at the flags JSON_C_OBJECT_ADD_* but it is not
for JSON_C_OBJECT_KEY_IS_CONSTANT.

From the point of vue of a developper using json-c,
the function json_object_object_add_ex is mainly used,
not the hash facility, it seems more natural to provide
a regular naming of prefix JSON_C_OBJECT_ADD_CONSTANT_KEY.

3 years agoMerge pull request #729 from DeX77/patch-1
Eric Hawicz [Sun, 17 Oct 2021 18:23:28 +0000 (14:23 -0400)]
Merge pull request #729 from DeX77/patch-1

* don't assume includedir

3 years ago* don't assume includedir
DeX77 [Fri, 15 Oct 2021 09:12:39 +0000 (11:12 +0200)]
* don't assume includedir

This change syncs the public header include install location with what gets written into pkgconfig file.

3 years agoMerge pull request #726 from leongross/fix/test-cmake3.1
Eric Hawicz [Sat, 9 Oct 2021 13:17:25 +0000 (09:17 -0400)]
Merge pull request #726 from leongross/fix/test-cmake3.1

fix cmake version for tests

3 years agofix cmake version for tests
Leon Gross [Wed, 6 Oct 2021 12:40:52 +0000 (14:40 +0200)]
fix cmake version for tests

3 years agoMerge pull request #722 from imaami/fix-json_tokener_new_ex-use-after-free
Eric Hawicz [Sun, 5 Sep 2021 03:16:13 +0000 (23:16 -0400)]
Merge pull request #722 from imaami/fix-json_tokener_new_ex-use-after-free

Fix use-after-free in json_tokener_new_ex()