Support merging values nested within objects. For instance, merging:
{
"foo": 1,
"bar": {
"baz": 2
}
}
with
{
"bar": {
"baz": 3
}
}
results in
{
"foo": 1,
"bar": {
"baz": 3
}
}
instead of overwriting the value for the bar key.
Add in diagnostics to json_load_dump_fuzzer so that if FUZZ_VERBOSE is
defined in the environment, additional debug information about the
current test case is output to stderr.
Replace json_dumps by json_dump_callback so that memory is not exhausted
by excessively nested json objects.
This patch adds two new exported functions:
* `jansson_version_str` - Returns a human-readable version number
* `jansson_version_cmp` - Returns an integer less than, equal to, or greater
than zero if the runtime version of Jansson is found, respectively, to be
less than, to match, or be greater than the provided major, minor, and micro.
pack_string should never free str on error. This wouldn't be a problem
except the check for `ours` was inverted. Just remove the check for
ours since the true condition is unreachable.
json_vpack_ex also had an error check for s.has_error. This can never
be true unless value is NULL.
Expand pack_unpack testing to cover empty format string, NULL object
value with non-null concatenated key, array containing a non-null object
after a NULL (error) string.
Fixes#444
* Replace 'tests/*' with '*/test/*'.
* Replace '/usr/*' with '/usr/include/*'. This resolves an issue where
it was impossible to test code coverage with the source in /usr/src.
* Ignore build/include/jansson.h as we just want src/jansson.h.
* Remove errant line-feed from pack_object error message.
* Correct error message in pack_object_inter.
* Create pack_integer / pack_real to get the correct error messages on
failure when packing numeric values.
* Add tests for packing NAN and infinity directly, in an array and as
an object value.
When NULL is received for an optional argument we should not set an
error message as this would block later error messages. If NULL is
received for a non-optional string we should set has_error. Set
has_error for UTF-8 errors to ensure optional strings with UTF-8
errors are not replaced with json_null(). Use 'purpose' argument in
NULL error messages of read_string.
Add error handling and tests for invalid formats where '+', '#', or '%'
is used on an optional string 's?' or 's*'.
Fix NULL string error messages to use 'purpose'.
Refactor skipping of '*' token, this is now handled by read_string and
pack_object_inter. This allows invalid format strings such as 's*#' and
's*+' to produce error messages.
Fixes#437
It was discovered fairly recently that JSON parsing libraries use
common pattern to name their exported symbols (they all use
json_ prefix). So eventually it happens that two symbols from two
different libraries have the same name. This will lead to cryptic
crashes (see [1] and [2]). Linking with -Bsymbolic-functions
prevents this.
1: https://gitlab.gnome.org/GNOME/json-glib/issues/33
2: https://groups.google.com/forum/#!topic/jansson-users/7Efx-RI45IU
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
As said in man doc:
"Each invocation of va_copy() must be matched by a corresponding
invocation of va_end() in the same function."
va_copy may alloc memory in some system, it's necessay to free it by
va_end.
Fixes: efe6c7b3f2 ("Add json_sprintf and json_vsprintf")
Signed-off-by: Xin Long <lucien.xin@gmail.com>