Alexandru Ardelean
4fb2eefac2
build,cmake: rename libjson-c-static.a to libjson-c.a
Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
8 years ago
Eric Haszlakiewicz
a36396992d
Merge pull request #321 from commodo/fix-cmake-vasprintf
build,cmake: fix vasprintf implicit definition and generate both static & shared libs
8 years ago
Eric Haszlakiewicz
e8e574fbe4
Issue #161 : add a json_object_to_fd() function.
8 years ago
Eric Haszlakiewicz
23e064ad29
Fix test_double_serializer expected output.
8 years ago
Eric Haszlakiewicz
1a94c70336
Add a json_c_set_serialization_double_format() function to set the *library-wide* format for how doubles are written to a serialized JSON output.
8 years ago
Eric Haszlakiewicz
8581806558
Make _set_last_err() non-static so it can be used outside of json_util.c
8 years ago
Eric Haszlakiewicz
e76ea37772
Merge pull request #325 from rouault/fix_stack_overflow_in_json_object_double_to_json_string_format
Fix stack buffer overflow in json_object_double_to_json_string_format()
8 years ago
Even Rouault
2c2deb87f8
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
8 years ago
Alexandru Ardelean
f10a5ae4d7
.gitignore: add cmake generated files
Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
8 years ago
Alexandru Ardelean
4b5e39c89c
build,cmake: generate both static and shared libjson
Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
8 years ago
Alexandru Ardelean
cfbbb23141
build,cmake: add _GNU_SOURCE to CFLAGS
Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
8 years ago
Eric Haszlakiewicz
6bd86d1044
Merge pull request #311 from jj1118/master
Fix error C3688 when compiling on Visual Studio 2015
8 years ago
Jason Li
0f81ecf5f4
Fix error C3688 when compiling on Visual Studio 2015: invalid literal suffix 'PRId64'; literal operator or literal operator template 'operator ""PRId64' not found
8 years ago
Eric Haszlakiewicz
4e673656a1
Merge pull request #310 from marxin/fix-gcc7-warnings
Add FALLTHRU comment to handle GCC7 warnings.
8 years ago
marxin
014924ba89
Add FALLTHRU comment to handle GCC7 warnings.
8 years ago
Eric Haszlakiewicz
82f5a4ab29
Merge pull request #305 from alexanderst/master
Fix compilation without C-99 option
8 years ago
Alex
175d934cff
Fix compilation without C-99 option
8 years ago
Eric Haszlakiewicz
8c86207258
Add a few more cases to test_parse to provide some examples of how parsing works; should help address the questions raised in Issue #302 .
8 years ago
Eric Haszlakiewicz
d74b7eb144
Merge pull request #303 from yogo1212/tokener_h
fix doc in tokener header file
8 years ago
Leon M. George
482e771af1
fix doc in tokener header file
8 years ago
Eric Haszlakiewicz
3948fcad2d
Issue #300 : Cast size_t values to int instead of unsigned long long to work around broken behavior of MinGW.
8 years ago
Eric Haszlakiewicz
bad6c9a427
Issue #300 : Some platforms, such as MinGW, don't have ETXTBSY and ENOTBLK, so skip those there.
8 years ago
Eric Haszlakiewicz
9a64fd7d55
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.
8 years ago
Eric Haszlakiewicz
91977159ee
Add cast to int in calls to isdigit() since some platforms complain about char being used as an array index.
8 years ago
Eric Haszlakiewicz
3fab117e4e
Merge pull request #299 from qlyoung/perf-improvements
Improve json_object -> string performance
8 years ago
Quentin Young
f6f852fd93
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%.
8 years ago
Eric Haszlakiewicz
75825a9f01
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.
8 years ago
Quentin Young
9ff0f4987f
Improve json_object -> string performance
Removes variadic prints for ~3x performance improvement.
8 years ago
Eric Haszlakiewicz
8157784483
Issue #295 : also check if size_t is the size of long long, to help support 64-bit Windows platforms.
8 years ago
Eric Haszlakiewicz
177c401e02
Ignore tests/test_float
8 years ago
Eric Haszlakiewicz
0a010a59eb
Change a memcpy that should be a memmove within json_pointer_get, and fix memory leaks in of one the json_pointer tests.
8 years ago
Eric Haszlakiewicz
779b77a164
Note some minimum versions needed for autoconf, etc...
8 years ago
Eric Haszlakiewicz
a443b9f7e7
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.
8 years ago
Eric Haszlakiewicz
1e4824a841
Merge pull request #289 from jgerhards/i-278
bugfix: floating point representaion without fractional part
8 years ago
Jan Gerhards
61db4cfac5
testbench: add test for floating point representation
8 years ago
Jan Gerhards
ca7a1973e2
bugfix: floating point representaion without fractional part
closes https://github.com/json-c/json-c/issues/278
8 years ago
Eric Haszlakiewicz
d050f1e622
Merge pull request #287 from commodo/json_pointer_va_args
json_pointer: extend setter & getter with printf() style arguments
8 years ago
Alexandru Ardelean
47f32a76ef
vasprintf_compat.h: spin-off this compat header ; use math_compat.h as template
Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
9 years ago
Alexandru Ardelean
8cb86a583a
strdup_compat.h: re-spin this compat header ; use math_compat.h as template
Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
9 years ago
Alexandru Ardelean
c0da680f13
test_json_pointer: update test with a few printf variants
Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
9 years ago
Alexandru Ardelean
742e059da1
json_pointer: add json_pointer_getf/setf() function variants
These include support for printf() style args for path.
Adds support for calling with 'json_pointer_getf(obj, &res, "/foo/%d/%s", 0, bar)'
style args.
Makes it easier for doing more dynamic stuff/magic, without
needing to use vasprintf() externally.
Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
9 years ago
Alexandru Ardelean
97dd7d5103
json_pointer.c: fix whitespace
Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
9 years ago
Eric Haszlakiewicz
8e12f4a21c
Merge pull request #285 from ebassi/revert-strdup-compat
Revert "compat/strdup.h: move common compat check for strdup() to own…
9 years ago
Emmanuele Bassi
7601f20d70
Revert "compat/strdup.h: move common compat check for strdup() to own file"
This reverts commit aaba8c1080
.
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.
9 years ago
Eric Haszlakiewicz
e8ce1db471
Merge pull request #283 from commodo/json_pointer
json_pointer: add first revision based on RFC 6901
9 years ago
Alexandru Ardelean
ee7fc26de1
tests: add test_json_pointer test
Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
9 years ago
Alexandru Ardelean
2fbdee19da
tests/strerror_override.c: fix compilation error
I got this on Mac OS X at least.
Not sure if it shows up in other envs
error:
```
strerror_override.c:53:13: error: incompatible redeclaration of library function 'strerror' [-Werror,-Wincompatible-library-redeclaration]
const char *strerror(int errno_in)
```
Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
9 years ago
Alexandru Ardelean
0e91183300
json_pointer: add first revision
Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
9 years ago
Alexandru Ardelean
aaba8c1080
compat/strdup.h: move common compat check for strdup() to own file
Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
9 years ago
Eric Haszlakiewicz
d4899bd4d5
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.
9 years ago