Commit Graph

1167 Commits

Author SHA1 Message Date
Robert Bielik
286b4fdd27 Fix uninitialized value error for clang-8 msan 2021-11-11 10:23:05 +01:00
Robert Bielik
a66a6cc51b Fix for clang ub sanitizer 2021-11-11 09:51:18 +01:00
Robert Bielik
21f767f63f Add target include dirs for static library as well 2021-11-11 09:37:53 +01:00
Eric Hawicz
9b0fb2b33e Merge pull request #727 from jobol/propo2
Really use prefix JSON_C_OBJECT_ADD_
2021-10-22 19:06:11 -04:00
José Bollo
8bf3b45a29 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.
2021-10-19 11:18:17 +02:00
Eric Hawicz
05c5d15075 Merge pull request #729 from DeX77/patch-1
* don't assume includedir
2021-10-17 14:23:28 -04:00
DeX77
d6d4b71d7d * don't assume includedir
This change syncs the public header include install location with what gets written into pkgconfig file.
2021-10-15 11:12:39 +02:00
Eric Hawicz
382f9462c2 Merge pull request #726 from leongross/fix/test-cmake3.1
fix cmake version for tests
2021-10-09 09:17:25 -04:00
Leon Gross
8be2ffdcd7 fix cmake version for tests 2021-10-06 15:29:33 +02:00
Eric Hawicz
4fc44f32df Merge pull request #722 from imaami/fix-json_tokener_new_ex-use-after-free
Fix use-after-free in json_tokener_new_ex()
2021-09-04 23:16:13 -04:00
Juuso Alasuutari
9361d8d3a8 Fix use-after-free in json_tokener_new_ex()
The failure path taken in the event of printbuf_new() returning NULL
calls free() on tok->stack after already having freed tok. Swap the
order of the two calls to fix an obvious memory access violation.

Fixes: bcb6d7d347 ("Handle allocation failure in json_tokener_new_ex")
Signed-off-by: Juuso Alasuutari <juuso.alasuutari@gmail.com>
2021-09-04 20:14:30 +03:00
Eric Hawicz
dc1ef7d566 Merge pull request #718 from Pawday/master
CMake create uninstall target if unix generator is used
2021-07-31 22:46:01 -04:00
Pawday
e91e4cc9fb Setted cmake "uninstall" target to exist in unix like operating systems only 2021-07-26 18:52:29 +03:00
Eric Haszlakiewicz
f61f1a7a91 Add workaround for Visual Studio not knowing about "inline". 2021-07-25 20:31:59 +00:00
Eric Haszlakiewicz
db6a6cc2b2 Switch the Travis build to use osx_image: xcode12.5, in an attempt to avoid timeouts with Homebrew. 2021-07-25 20:03:55 +00:00
Eric Haszlakiewicz
6a0df2609e Merge some old work to include (some of) PR #464 into the current master branch. 2021-07-25 19:07:06 +00:00
Eric Haszlakiewicz
8c727e5ce1 Only define an "uninstall" target if it's not already defined (e.g. by projects that include json-c) 2021-07-25 15:11:11 +00:00
Eric Hawicz
be9671e48a Merge pull request #714 from Hex052/clang-format_AfterCaseLabel
Add AfterCaseLabel to .clang-format
2021-07-05 18:18:06 -04:00
Hex052
9dde931a1c Add AfterCaseLabel to .clang-format
This is to fix the behavior that might've changed between older versions of clang-format, I'm not sure.
Version 10 tries to put the bracket on the same line as case without this.
2021-07-04 18:28:21 -08:00
Eric Haszlakiewicz
75bf657cc2 If inttypes.h is present, use it, even on Windows. 2021-06-13 21:12:22 +00:00
Eric Haszlakiewicz
9ca50cf2f8 Issue #709: adjust some include guards to be a bit more json-c specific. 2021-06-02 23:53:23 +00:00
Eric Hawicz
0b7e78c309 Merge pull request #706 from davidjmccann/master
Check __STDC_VERSION__ is defined before checking its value
2021-05-15 08:41:24 -04:00
David McCann
00098efc96 Merge branch 'json-c:master' into master 2021-05-13 06:34:10 +01:00
David McCann
9b53c92ea3 Check __STDC_VERSION__ is defined before checking its value
Prevent an undef warning regarding __STDC_VERSION__ by checking whether it is defined before checking its value.
2021-05-13 06:31:18 +01:00
Eric Hawicz
cd7109f767 Merge pull request #696 from ssrlive/master
To avoid target exe file export JSON functions.
2021-05-01 15:21:31 -04:00
Eric Hawicz
78e390a261 Merge pull request #701 from commodo/configurable-opts
[RFC] json_pointer: allow the feature to be disabled
2021-04-17 17:26:49 -04:00
Alexandru Ardelean
8abeebc9b2 json_pointer: allow the feature to be disabled
Some users may not want to included it in their build/system. So allow a
cmake symbol to disable it.

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

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

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
2021-04-16 11:49:38 +03:00
Alexandru Ardelean
1f8b64f62c tests: CMakeLists.txt: move test names to variable
The intent is to be able to disable some features that get built into the
library. When we do that, we also need to disable some tests.

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

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
2021-04-16 09:32:17 +03:00
Eric Hawicz
94909840be Merge pull request #700 from Philosoph228/werror-fix
Fix unused variable for Win32 build in random_seed.c
2021-04-14 22:38:36 -04:00
Philosoph228
9c0565100a random_seed: fix unused variable for win32 build 2021-04-13 11:47:01 +05:00
ssrlive
ba181548bc To avoid target exe file export JSON functions. 2021-03-02 14:27:40 +08:00
Eric Haszlakiewicz
041cef434a Add a DISABLE_EXTRA_LIBS option to skip using libbsd, per @neheb's request on issue #692/commit 0f61f692. 2021-02-15 20:19:56 +00:00
Eric Haszlakiewicz
f787810890 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. 2021-02-13 03:23:58 +00:00
Eric Hawicz
7c859c54e4 Merge pull request #694 from ihsinme/patch-1
fix invalid unsigned arithmetic.
2021-02-06 17:25:24 -05:00
ihsinme
c456963110 Update json_object.c 2021-02-05 18:58:20 +03:00
Eric Haszlakiewicz
0f61f6921b Iesue #692: use arc4random() if it's available (in libc on BSD systems, and libbsd on Linux). 2021-01-13 01:57:25 +00:00
Eric Haszlakiewicz
69d650528d Keep the doc directory in the nodoc release tarball, just exclude its contents. 2021-01-13 01:30:16 +00:00
Eric Hawicz
4754f47434 Merge pull request #674 from ploxiln/random_seed_err_continue
random_seed: on error, continue to next method
2021-01-12 20:22:54 -05:00
Eric Hawicz
1fcb9e476b Merge pull request #689 from neheb/patch-1
fix compilation with clang
2020-12-18 21:30:14 -05:00
Rosen Penev
987d3b2c86 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);
2020-12-17 19:59:37 -08:00
Pierce Lopez
0fd3b7d316 random_seed: on error, continue to next method
instead of exiting the process
2020-10-07 01:22:30 -04:00
Eric Hawicz
df27756491 Merge pull request #667 from stoeckmann/regression
Fixed test1 regression.
2020-09-11 20:56:51 -04:00
Tobias Stoeckmann
7af593c140 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.
2020-09-11 21:09:40 +02:00
Eric Hawicz
785a94b7a2 Merge pull request #665 from stoeckmann/tokener
Handle more allocation failures in json_tokener* functions
2020-08-24 09:51:41 -04:00
Eric Hawicz
eb08a92218 Merge pull request #660 from stoeckmann/arraylist
Validate size arguments in arraylist functions.
2020-08-24 09:51:18 -04:00
Tobias Stoeckmann
369e8477d2 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.
2020-08-24 12:13:50 +02:00
Eric Hawicz
b4e72c2655 Merge pull request #664 from stoeckmann/string
Limit strings at INT_MAX length
2020-08-23 16:43:31 -04:00
Eric Hawicz
f941931804 Merge pull request #663 from stoeckmann/strerror
Properly format errnos in _json_c_strerror
2020-08-23 16:38:21 -04:00
Eric Hawicz
1bc7a6b223 Merge pull request #662 from stoeckmann/random
Prevent signed overflow in get_time_seed
2020-08-23 16:34:40 -04:00
Tobias Stoeckmann
df62119b7f 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.
2020-08-22 13:25:21 +02:00