Commit Graph

203 Commits

Author SHA1 Message Date
Eric Haszlakiewicz
85c244f048 Eliminate unnecessary cast that was added to test_double_serializer. 2020-06-07 18:50:10 +00:00
Eric Haszlakiewicz
66d91fdf86 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.
2020-06-07 17:23:56 +00:00
Eric Haszlakiewicz
0fc9d91277 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.
2020-06-07 02:56:59 +00:00
Eric Haszlakiewicz
9ecb1222bd 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.
2020-05-26 02:31:35 +00:00
Eric Haszlakiewicz
02b687b9a6 Kick json_type_array out of struct json_object; re-enable the test_deep_copy test. 2020-05-25 03:44:56 +00:00
Eric Haszlakiewicz
853b4b5dee Start splitting struct json_object into multiple sub-types, as descibed at https://github.com/json-c/json-c/wiki/Proposal:-struct-json_object-split
The current changes split out _only_ json_type_object, and thus have a number of hacks
 to allow the code to continue to build and work.

Originally  mentioned in issue #535.
When complete, this will probably invalidate #552.
This is likely to cause notable conflicts in any other significant un-merged
changes, such as PR#620.
2020-05-25 03:18:36 +00:00
Björn Esser
3008401b2a test_deep_copy: Fix assertion value. 2020-05-18 17:06:37 +02:00
Björn Esser
dd040ba446 tests: Fix test_double_serializer without thread-local storage. 2020-05-18 12:27:00 +02:00
Tobias Stoeckmann
5385a566db Prevent truncation on custom double formatters.
A custom double formatter can lead to truncation of the rest of the
JSON document.

If a custom formatter completely fills the buffer used by snprintf
with a trailing dot or comma and the formatting option
JSON_C_TO_STRING_NOZERO has been specified, then an iterator moves
past the ending '\0' (off-by-one buffer overflow) to set an
additional '\0' and adds the first '\0' into the printbuf.

Since '\0' will eventually be considered the terminating character
of the complete printbuf result, all trailing characters are lost.

This leads to an incomplete JSON string as can be seen with the
test case.

The off-by-one can be noticed if compiled with address sanitizer.

Since this is a very special case and a malformed formatter could
do way more harm and is the responsibility of the user of this
library, this is just a protective measure to keep json-c code as
robust as possible.
2020-05-16 15:26:16 +02:00
David McCann
add7b13a9a Improved support for IBM operating systems
Fix compiler errors and warnings when building on IBM operating systems such as AIX and IBM i.
2020-05-14 15:39:35 +01:00
Pierce Lopez
003b58782b fix json_parse_uint64() usage of errno
introduced in #542
fixes #601
2020-05-10 13:38:12 -04:00
Eric Haszlakiewicz
26f080997d Fix snprintf on windows problem for test4. 2020-05-10 04:04:28 +00:00
Eric Haszlakiewicz
a59d5acfab Re-format after recent change to fix linkhash. 2020-05-10 03:58:27 +00:00
Eric Haszlakiewicz
519dfe1591 Issue #599: Fix the backwards check in lh_table_insert_w_hash() that was preventing adding more than 11 objects.
Add a test to check for this too.
2020-05-10 03:36:05 +00:00
Eric Haszlakiewicz
f6f76f9430 Add a JSON_TOKENER_ALLOW_TRAILING_CHARS flag for json_tokener_set_flags() to allow multiple objects to be parsed from input even when JSON_TOKENER_STRICT is set. 2020-04-21 03:53:44 +00:00
Eric Haszlakiewicz
05623b3a2e Add an tok_flags field to explicitly specify tokener flags in test_parse and eliminate the previous bogus calls to json_tokener_set_flags() 2020-04-21 03:53:44 +00:00
Eric Haszlakiewicz
a9114392b4 Merge pull request #524 from dota17/addTestCase_obj_token
Increase coverage
2020-04-15 23:35:21 -04:00
dota17
b14363ae32 remove unsuitable case 2020-04-15 20:06:12 +08:00
dota17
2876fcc137 clang-format two test_util_file.c and test_object_iterator.c 2020-04-14 10:15:27 +08:00
chenguoping
8096125618 Increased the test coverage of json_util.c from 76% to 90.3%. 2020-04-14 10:10:47 +08:00
chenguoping
f56c5c1a60 Increased the test coverage of json_object_iterator.c from 0% to 100% 2020-04-14 10:03:58 +08:00
dota17
74bbe349c4 clang-format test1.c 2020-04-14 09:20:51 +08:00
chenguoping
110c60fcdd fix valgrind errors 2020-04-14 09:13:29 +08:00
chenguoping
76e1472808 testcase for array_list 2020-04-14 09:13:06 +08:00
Björn Esser
5e699f7f73 Be verbose on failing json_c_version test. 2020-04-11 21:09:31 +02:00
Eric Haszlakiewicz
c58d56ab7c Merge pull request #576 from besser82/topic/besser82/increase_coverage
Test coverage for json_c_version.
2020-04-11 14:45:45 -04:00
Björn Esser
d47fb12e85 Test coverage for json_c_version. 2020-04-11 12:33:59 +02:00
Björn Esser
73a2ed115a Remove multiple trailing newlines at EOF. 2020-04-11 10:35:42 +02:00
Björn Esser
78cd37fb18 Clean trailing white-space. 2020-04-11 09:41:04 +02:00
Eric Haszlakiewicz
95737df9d4 Remove autoconf machinery, we're using cmake now. Update the release checklist to account for that, plus fill in other tasks and clean it up a bit. 2020-04-09 02:15:31 +00:00
dota17
8b162c4b89 clang-format the files 2020-04-03 11:39:30 +08:00
dota17
c117d8a8a8 add the disabling formatting coments and adjust the partial code manuly 2020-04-03 11:28:04 +08:00
dota17
3822177473 add test cases 2020-03-31 19:12:45 +08:00
Eric Haszlakiewicz
a8c9284f06 Merge pull request #547 from dota17/assert_test
modify json-c default build type, and fix up the assert() errors in t…
2020-03-03 07:54:21 -06:00
dota17
e56ab0146f update testcase and delete debug -O0 build 2020-03-02 20:19:35 +08:00
dota17
2d44f865c3 modify json-c default build type, and fix up the assert() errors in testcase 2020-02-29 15:32:42 +08:00
dota17
6359b79847 update json_object.c and testcase, delete json_object_uint_inc() 2020-02-28 17:51:56 +08:00
dota17
9532f94fa4 modify partial functions and testcase, in order to support automatic conversion for int64/uint64 2020-02-28 09:25:02 +08:00
dota17
c816de212b modify the json_object, replace c_int64/c_uint64 with struct{union{int64, uint64},...} 2020-02-27 10:26:27 +08:00
dota17
3c3b5920f7 add uint64 data to json-c 2020-02-25 14:51:35 +08:00
Eric Haszlakiewicz
4bf7ffa984 Issue #539: be sure to clean up at the end of test_set_value. 2020-02-14 03:25:46 +00:00
Eric Haszlakiewicz
ae13ca524a Issue #539: reset the serializer when json_object_set_double() is called and the current serializer is the one that json_object_new_double_s() used. 2020-02-13 03:11:10 +00:00
Eric Haszlakiewicz
0ffdbb2395 Merge pull request #531 from dota17/utf8test
validate utf-8 string
2020-02-05 21:56:06 -05:00
dota17
010f33d460 add json_object_new_null 2020-01-20 16:46:46 +08:00
dota17
787a8b3f1c update code 2020-01-20 10:41:24 +08:00
Po-Chuan Hsieh
bb5971ba2a Fix make check
cc -DHAVE_CONFIG_H -I. -I..  -I.. -I../tests    -O2 -pipe  -fstack-protector-strong -fno-strict-aliasing  -Wall -Werror -Wcast-qual -Wno-error=deprecated-declarations -Wextra -Wno-unused-parameter -D_GNU_SOURCE -D_REENTRANT -MT test_parse.o -MD -MP -MF .deps/test_parse.Tpo -c -o test_parse.o test_parse.c
test_parse.c:256:14: error: adding 'int' to a string does not append to the string [-Werror,-Wstring-plus-int]
        { "null123" + 4,       4, 3, json_tokener_success, 1 },
          ~~~~~~~~~~^~~
test_parse.c:256:14: note: use array indexing to silence this warning
        { "null123" + 4,       4, 3, json_tokener_success, 1 },
                    ^
          &         [  ]
test_parse.c:258:12: error: adding 'int' to a string does not append to the string [-Werror,-Wstring-plus-int]
        { "nullx" + 4,         2, 0, json_tokener_error_parse_unexpected, 1 },
          ~~~~~~~~^~~
test_parse.c:258:12: note: use array indexing to silence this warning
        { "nullx" + 4,         2, 0, json_tokener_error_parse_unexpected, 1 },
                  ^
          &       [  ]
test_parse.c:260:25: error: adding 'int' to a string does not append to the string [-Werror,-Wstring-plus-int]
        { "{\"a\":1}{\"b\":2}" + 7,
          ~~~~~~~~~~~~~~~~~~~~~^~~
test_parse.c:260:25: note: use array indexing to silence this warning
        { "{\"a\":1}{\"b\":2}" + 7,
                               ^
          &                    [  ]
3 errors generated.
*** Error code 1

Stop.
2020-01-11 07:20:44 +00:00
dota17
eca74dcccf test utf8 2020-01-10 18:33:14 +08:00
Eric Haszlakiewicz
e651e96a5b Merge pull request #526 from dota17/addTestCase_printbuf
Increased the test coverage of printbuf.c 82% to 92%.
2020-01-03 08:32:53 -05:00
Eric Haszlakiewicz
a255510cca Merge pull request #525 from dota17/addPointerTestcase
update pointer test case
2020-01-03 08:31:41 -05:00
chenguoping
8c0cb0bd28 Increased the test coverage of printbuf.c 82% to 92%. 2020-01-03 14:34:35 +08:00