Haffon [Tue, 22 Aug 2017 05:53:47 +0000 (13:53 +0800)]
1.make it can been compiled with Visual Studio 2010
2.replace json_object_get/put API with json_object_retain/release, as they operate the reference counter, and confused with array_list_get/put_idx.
3.replace array_list_get/put_idx API with array_list_get/insert to make them more clear to use.
PR #336: since we can't use function overriding (due to problems with it on
OSX) always include the _json_c_strerror function but only enable it with a flag
during tests.
PR #336: since we can't use function overriding (due to problems with it on OSX) always include the _json_c_strerror function but only enable it with a flag during tests.
If we want to override `strerror()` in libjson-c
to make tests consistent across platforms, we
need to do it build-wide as configure/build
option.
Apple linkers make it really hard to override functions
at link-time, and this seems to be locked down on travis-ci.org
[ for security reasons I assume ].
While I got it to work locally, it did not work
when running on travis.
Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
tests: add `set -e` specifier to bail early on build run
Seems that test1 is failing, but travis is not catching it.
Likely, this is because the `cppcheck` returns success
and we need to bail on the `make check` step.
Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Comment out the warning about racy random seed initialization in lh_char_hash(), if you're on a platform where it'll be triggered it just makes it a pain to build.
Issue #308: improve the build instructions in README.md to include the exact commands to run for installing prerequisites, as mentioned earlier on Issue #308.
Issue #332: fix a long-standing bug in array_list_put_idx() where it would attempt to free previously free'd entries due to not checking the current array length.
Add a test that triggers the problem to ensure it stays fixed.
Even Rouault [Thu, 18 May 2017 20:36:35 +0000 (22:36 +0200)]
Fix stack buffer overflow in json_object_double_to_json_string_format()
Issue originally found in the json-c 0.11 internal copy in GDAL but also found
in latest git version.
If doing things like
json_object* obj = json_object_new_double(1e300);
json_object_set_serializer(obj, json_object_double_to_json_string, "%f", NULL);
json_object_to_json_string(obj)
size = snprintf(buf, sizeof(buf),
format ? format :
(modf(jso->o.c_double, &dummy) == 0) ? "%.17g.0" : "%.17g",
jso->o.c_double);
will return a value greater than 128 since at least 300 characters are needed.
This value is then passed to printbuf_memappend(pb, buf, size); that tries to
read size bytes in buf.
So we should clamp size to sizeof(buf). And on Windows, _snprintf() returns -1
in that situation, so deal also with this case.
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1682
Credit to OSS-Fuzz
Pablo Sanabria [Sat, 25 Mar 2017 22:18:29 +0000 (19:18 -0300)]
Fixed linkhash.c for MinGW
Added #ifdef conditions for MinGW because this compiler doesn't define
gcc atomic builtins, so __sync_val_compare_and_swap was not found
neither any of any __GCC_HAVE_SYNC_COMPARE_AND_SWAP_* definition
Pablo Sanabria [Sat, 25 Mar 2017 19:31:22 +0000 (16:31 -0300)]
Fix CMake Build process for MinGW and MSYS2
This fix includes some fixes for config.h.win32 that was generating
some compiling errors on MinGW64 and also fix CMakeLists.txt in order to
give better support to MinGW and MSYS2
Jason Li [Fri, 24 Mar 2017 06:53:25 +0000 (14:53 +0800)]
Fix error C3688 when compiling on Visual Studio 2015: invalid literal suffix 'PRId64'; literal operator or literal operator template 'operator ""PRId64' not found
Issue #300: Use %p instead of %lx in test_util_file since some platforms' pointers are larger than "unsigned long".
Also, there's no need to worry about output consistency here, since it'll be
different anyway due to different pointer values.
Quentin Young [Fri, 3 Feb 2017 21:43:59 +0000 (21:43 +0000)]
Restore sprintbuf(), add macro for string literals
Hawciz pointed out that the previous commit modifies the public
interface of printbuf. Per his suggestion, sprintbuf() was restored
and a new pair of macros was added that wraps printbuf_memappend().
Using a wrapper macro instead of modifying sprintbuf() also reduces
function call overhead, bringing total performance gains to
approximately 400%.
Use strdup instead of strndup in test1.c, there's no need for the latter because json_object_to_json_string_length() will always return a properly sized string.
Issue#292: bump the required version of configure listed in configure.ac so a more useful error message is generated, rather than failing later because the extra macros from ./autoconf-archive/m4/ didn't get loaded.
This commit breaks builddir != srcdir build, but, more importantly, it
also adds a dependency on a header, "config.h", which is not installed
and it's supposed to be private — since it's generated at configuration
time and it's not meant to be used by projects compiling against a
library.
Handle NULL objects in json_object_get_userdata() by returning NULL, but abort in json_object_set_userdata() since we can't actually do anything with the userdata.