summaryrefslogtreecommitdiff
path: root/json_object.c
Commit message (Collapse)AuthorAgeFilesLines
...
| * | Clamp double to int32 when narrowing in json_object_get_int.Kurt Schwehr2017-08-081-0/+4
| | | | | | | | | | | | Avoids undefined behavior. Found by autofuzz.
* | | 1.make it can been compiled with Visual Studio 2010Haffon2017-08-221-12/+15
|/ / | | | | | | | | 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.
* | build: make `strerror()` override-ableAlexandru Ardelean2017-07-131-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Move a variable declaration to the start of the block to work better with ↵Eric Haszlakiewicz2017-07-091-1/+1
| | | | | | | | older compilers.
* | Add extra casts to void * to squash some warning on certain systems (e.g. ↵Eric Haszlakiewicz2017-07-091-3/+3
| | | | | | | | CentOS w/ gcc 4.1.2).
* | Fix bad usage of strncat introduces in 1a94c70. Pointed out by @rouault in ↵Eric Haszlakiewicz2017-07-091-4/+3
| | | | | | | | PR #331.
* | Eliminate static qualifiers on a couple local variables that were causing ↵Eric Haszlakiewicz2017-07-091-2/+2
| | | | | | | | thread safety issues. Suggested by @rouault in PR #331.
* | Reformat json_object_double_to_json_string_format() to have consistent spacing.Eric Haszlakiewicz2017-07-081-30/+34
| |
* | Add a json_c_set_serialization_double_format() function to set the ↵Eric Haszlakiewicz2017-06-181-9/+76
| | | | | | | | *library-wide* format for how doubles are written to a serialized JSON output.
* | Fix stack buffer overflow in json_object_double_to_json_string_format()Even Rouault2017-05-181-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Fix error C3688 when compiling on Visual Studio 2015: invalid literal suffix ↵Jason Li2017-03-241-1/+1
| | | | | | | | 'PRId64'; literal operator or literal operator template 'operator ""PRId64' not found
* | Add FALLTHRU comment to handle GCC7 warnings.marxin2017-03-211-0/+1
| |
* | Restore sprintbuf(), add macro for string literalsQuentin Young2017-02-041-31/+30
| | | | | | | | | | | | | | | | | | | | 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%.
* | Improve json_object -> string performanceQuentin Young2017-02-021-4/+11
| | | | | | | | Removes variadic prints for ~3x performance improvement.
* | bugfix: floating point representaion without fractional partJan Gerhards2016-11-271-1/+4
| | | | | | | | closes https://github.com/json-c/json-c/issues/278
* | strdup_compat.h: re-spin this compat header ; use math_compat.h as templateAlexandru Ardelean2016-11-221-7/+1
| | | | | | | | Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
* | Revert "compat/strdup.h: move common compat check for strdup() to own file"Emmanuele Bassi2016-11-071-1/+7
| | | | | | | | | | | | | | | | | | | | This reverts commit aaba8c1080533133329086e47f4f45981dfdd1ee. 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.
* | compat/strdup.h: move common compat check for strdup() to own fileAlexandru Ardelean2016-11-031-7/+1
| | | | | | | | Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
* | Handle NULL objects in json_object_get_userdata() by returning NULL, but ↵Eric Haszlakiewicz2016-10-291-1/+4
| | | | | | | | abort in json_object_set_userdata() since we can't actually do anything with the userdata.
* | Issue #280: add a few assert() calls to ensure objects are of the ↵Eric Haszlakiewicz2016-10-291-4/+19
| | | | | | | | appropriate type.
* | Merge pull request #277 from ALLTERCO/json_object_set_xxxEric Haszlakiewicz2016-10-081-1/+49
|\ \ | | | | | | Json object set xxx
| * | try restore windows automated buildsStoian Ivanov2016-10-071-1/+1
| | |
| * | fix compiler warning for int sizesStoian Ivanov2016-10-071-1/+1
| | |
| * | string set and testsStoian Ivanov2016-10-071-0/+21
| | |
| * | some basic setStoian Ivanov2016-10-051-3/+23
| | |
| * | json_object_set_boolean for upstream style checkStoian Ivanov2016-09-211-0/+7
| | |
* | | fixed wrong object name in json_object_all_values_equalAlexey Konovalov2016-09-271-1/+1
|/ /
* | Issue #260: add a check to prevent trivial loops in the object tree, even ↵Eric Haszlakiewicz2016-08-201-0/+6
| | | | | | | | though it is up to the callers to avoid doing so in more complex cases.
* | json_object_object_add_ex() should have shared code with ↵Eric Haszlakiewicz2016-08-201-26/+11
| | | | | | | | | | | | json_object_object_add(), and been changed to return int at the same time the latter was. Do that now. Also correct a couple of calls to _to_json_string to check the return value.
* | Revert bogus change to json_object_get() made in f40b08d8 that caused it to ↵Eric Haszlakiewicz2016-08-111-1/+1
| | | | | | | | | | | | | | | | always return NULL. (Issue #259) Also undo NULL check in json_tokener_set_flags(): it's not at all valid toi try to set flags on a NULL pointer, and doing so should not be silently ignored.
* | Merge pull request #255 from RyDroid/minor-c2Eric Haszlakiewicz2016-08-101-23/+30
|\ \ | | | | | | Minor changes in C source code
| * | Minor changes in C source codeNicola Spanti (RyDroid)2016-08-081-23/+30
| | |
* | | Add method 'json_object_to_json_string_length'jobol2016-07-271-9/+24
|/ / | | | | | | | | | | | | | | | | | | This new method allows to also get the length of the generated string. Fix #165 Change-Id: Iea91404027f143ca3d29a4c58d7c07ae53556110 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
* | Issue #236: Add -Wcast-qual and fix casts to retain constness.Eric Haszlakiewicz2016-06-111-13/+13
| | | | | | | | | | To better distinguish between entry->k and entry->v being const within linkhash, but non-const outside, add lh_entry_v() and lh_entry_k() accessors. Make lh_entry->k const.
* | Add public API to get and set userdataMatthias Schiffer2016-05-291-9/+16
| | | | | | | | | | Also, json_object_set_serializer is changed to respect the userdata and user_delete parameters when to_string_func is NULL.
* | Make default double serializer ignore userdata againMatthias Schiffer2016-05-291-7/+27
| | | | | | | | | | | | | | | | The user might want to use the userdata for something different, so the serializer should ignore it by default. Explicitly setting the serializer to json_object_double_to_json_string will still make it interpret the userdata as a format string.
* | Fix a few places that needed adjustment for the size_t changes, including ↵Eric Haszlakiewicz2016-05-231-2/+2
| | | | | | | | updating the range checks to use a calculated SIZE_T_MAX.
* | Merge branch 'fixes-for-upstream' of https://github.com/doctaweeks/json-c ↵Eric Haszlakiewicz2016-05-231-4/+4
|\ \ | | | | | | | | | into doctaweeks-fixes-for-upstream
| * | Use size_t for json object array opsDaniel M. Weeks2015-11-241-4/+4
| |/
* | Export json_object_double_to_json_string() and use custom format stringJan-Philipp Litza2016-05-061-6/+6
| |
* | Merge branch 'master' of https://github.com/Protovision/json-c into ↵Eric Haszlakiewicz2016-04-301-0/+5
|\ \ | | | | | | | | | Protovision-master
| * | Added array_list_del_idx and json_object_array_del_idxMark Swoope2015-04-021-0/+4
| | |
* | | Merge pull request #219 from rouault/low_heap_robustness_fixesEric Haszlakiewicz2016-04-301-0/+5
|\ \ \ | | | | | | | | Fix various potential null ptr deref and int32 overflows
| * | | Fix various potential null ptr deref and int32 overflowsEven Rouault2016-01-111-0/+5
| | | | | | | | | | | | | | | | | | | | This fix errors that can happen when ingesting very large JSON files when hitting the maximum heap size of the process.
* | | | Merge pull request #220 from hschaa/masterEric Haszlakiewicz2016-04-301-0/+81
|\ \ \ \ | | | | | | | | | | Add utility function for comparing json_objects
| * | | | Add utility function for comparing json_objectsHelmut Schaa2016-01-131-0/+81
| |/ / /
* | | | Fix issue #221: JSON_C_TO_STRING_NOSLASHESCAPE works incorrectlychenha02016-01-211-6/+6
|/ / / | | | | | | | | | Tests added.
* | | Add const qualifiers to several functions that don't modify the json_object.Eric Haszlakiewicz2015-12-261-15/+15
| | |
* | | Merge commit '2be921d88376e78f84d79aafa6db2714da804e59'Eric Haszlakiewicz2015-12-081-3/+8
|\ \ \
| * | | Fixed json_object_object_add().Alexander Klauer2013-01-081-3/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Return value of json_object_object_add() changed from void to int. Return value now indicates success or failure. * Check whether allocations are successful. * Do not exit program from within the library.