Commit Graph
1482 Commits
Author SHA1 Message Date
Javid Khan 510d68bd35 reject negative after whitespace in json_parse_uint64 2026-08-17 20:37:45 +05:30
Eric Hawicz 81092b3072 Merge pull request #948 from thesamesam/meson
meson: wire up `disable_extra_libs` option
2026-08-17 01:16:31 -04:00
Eric Hawicz 8319071e2b Merge pull request #957 from dngr2/fix/strict-number-grammar
Check the whole RFC 8259 number grammar in strict mode
2026-08-16 21:37:39 -04:00
Denis Gregor e222189360 Check the whole RFC 8259 number grammar in strict mode
Strict mode rejected leading zeros but nothing else about the shape of a
number, so several malformed numbers parsed and were then written back out
verbatim, producing JSON that other parsers reject:

    $ echo '[2.e3]' | ./json_parse -s -
    [ 2.e3 ]

RFC 8259 requires a mandatory integer part and at least one digit in both the
fraction and the exponent:

    number = [ minus ] int [ frac ] [ exp ]
    int    = zero / ( digit1-9 *DIGIT )
    frac   = decimal-point 1*DIGIT
    exp    = e [ minus / plus ] 1*DIGIT

so "1.", "-2.", "2.e3", "2.e+3", "0.e1", "-.123", "1e" and "1e+" are all
invalid. Walk the accumulated text against that grammar instead. The leading
zero rule from the previous check is part of the same walk rather than a
separate test, and its cases keep their coverage.

Only JSON_TOKENER_STRICT is affected; the default tokener stays as lenient as
it was. Measured against JSONTestSuite (318 files): strict mode went from 44
to 37 files accepted that the suite says must be rejected, default mode stayed
at 71, and nothing that must be accepted regressed in either mode.
2026-08-16 20:26:15 +03:00
Eric Hawicz 27bf659204 Merge the two meson checks for arc4random, instead have the has_function loop check first without, then with the dependencies. 2026-08-15 10:58:04 -04:00
Eric Hawicz 892c204ce0 Merge pull request #955 from carrerasdarren-cell/agent/fix-printbuf-self-append
printbuf: preserve self-append sources across growth
2026-08-15 10:10:20 -04:00
Darren Carreras 9782370c3f Address printbuf review comments 2026-08-09 20:01:12 -04:00
Eric Hawicz c0d4626175 Merge pull request #953 from dxbjavid/number-leading-zero-strict
reject leading zeros in strict-mode number parsing
2026-08-03 21:11:40 -04:00
Darren Carreras 62bb838c57 printbuf: preserve self-append sources across growth
When the appended data points into the printbuf itself, growing the buffer may invalidate the source pointer before it is copied. Preserve the source offset across realloc and use memmove for internal overlap.
2026-08-01 14:12:56 -04:00
Javid Khan ff18c75286 reject leading zeros in strict-mode number parsing 2026-07-28 13:27:25 +05:30
Tyler Erickson 133b0b8322 make: Fixing missing math dependency in non-Windows json-c builds with meson
The -lm was missing in the pkgconfig file that was generated. This adds that similar to the CMake build system's output.

Signed-off-by: Tyler Erickson <tyler.erickson@seagate.com>
Signed-off-by: Sam James <sam@gentoo.org>
2026-07-24 14:14:11 +01:00
Sam James 2419dbd2ea meson: fix pkgconfig file
Fix includedir and libdir to have proper paths (not just relative ones
to prefix).

Using Meson's native pkgconfig module is the best way of doing this.

Signed-off-by: Sam James <sam@gentoo.org>
2026-07-24 07:37:41 +01:00
Sam James 7ee487cc61 meson: fix version numbers
Signed-off-by: Sam James <sam@gentoo.org>
2026-07-24 07:37:41 +01:00
Sam James 87087ded64 meson: improve test handling
Tests will now be built at `meson test`-time, so there's no cost if the
user isn't going to run them.

This is better than guarding on build type, as distros may want to test production
builds before shipping.

Signed-off-by: Sam James <sam@gentoo.org>
2026-07-24 07:37:41 +01:00
Sam James cf958091ad meson: wire up extra_libs option
This is more elegant as a meson feature option because feature options
propagate in a useful way to `dependency(..., required: ...)`.

Without this, the option was ignored. Wiring it up naively meant that
disabling it still searched for libbsd as well, so a feature option
is the best fit.

Also, mark it as a dependency of `arc4random`.

Signed-off-by: Sam James <sam@gentoo.org>
2026-07-24 07:37:40 +01:00
Eric Hawicz 1bd2e4b3ef Merge pull request #949 from dxbjavid/pointer-empty-index-token
reject empty reference token as array index in json_pointer
2026-07-21 19:45:12 -04:00
Javid Khan 70f3169bae reject empty reference token as array index in json_pointer 2026-07-20 14:44:51 +05:30
Eric Hawicz 1e39345938 Merge pull request #946 from dxbjavid/patch-null-field-fields
reject null op/path/from fields in json_patch_apply
2026-07-18 13:15:09 -04:00
Javid Khan e248056aa1 require string type for patch op/path/from fields 2026-07-18 21:08:17 +05:30
Javid Khan eed664e06a reject null op/path/from fields in json_patch_apply 2026-07-16 12:55:41 +05:30
Eric Hawicz 0ea5f6c615 Merge pull request #942 from dxbjavid/strerror-negative-oob
fix out-of-bounds read for negative errno in _json_c_strerror
2026-07-16 00:42:42 -04:00
Eric Hawicz f61e612b43 Merge pull request #943 from Seagate/meson_install_fix
fix installing json-c headers with meson and missing pkgconfig file
2026-07-16 00:41:29 -04:00
Eric Hawicz dfd37bc1bb Merge pull request #945 from arr2036/json-object-put-return-value
fix json_object_put() to return 1 for freed scalars and empty containers
2026-07-16 00:40:55 -04:00
Arran Cudbard-Bell 69be99ef8e fix json_object_put() to return 1 for freed scalars and empty containers
The iterative rewrite in 17328a67 made json_object_put() return 0 for freed scalars, strings and empty containers, contradicting the documented contract in json_object.h. Distinguish "freed" from "still referenced" in _json_object_put_maybe_free() and add regression tests.
2026-07-14 10:28:04 -04:00
Tyler Erickson 56a0e3f478 fix installing json-c headers with meson and missing pkgconfig file
This commit fixes the install path for json-c headers when running `meson install`.
Previously some showed in /usr/include/ rather than /usr/include/json-c

This also adds generating the pkgconfig .pc file for this project.

Signed-off-by: Tyler Erickson <tyler.erickson@seagate.com>
2026-07-13 15:48:20 -06:00
Javid Khan 9d116a5d38 fix out-of-bounds read for negative errno in _json_c_strerror 2026-07-13 13:46:36 +05:30
Eric Hawicz e65444a258 Merge pull request #940 from dxbjavid/get-int64-double-boundary
reject out-of-range double in json_object_get_int64/get_uint64
2026-07-12 19:46:03 -04:00
Eric Hawicz aab792578b Issue #941: fix "defined but not used" errors when building with a c++ compiler. 2026-07-11 09:28:49 -04:00
Javid Khan 16e394ba96 reject out-of-range double in get_int64/get_uint64 2026-07-06 18:07:09 +05:30
Eric Hawicz 324e5ca593 Merge pull request #933 from dxbjavid/int-inc-int64min-overflow
fix signed overflow negating INT64_MIN in json_object_int_inc
2026-07-04 11:40:42 -04:00
Eric Hawicz 0c3a5a1994 Issue #934: Also set _userdata=NULL in _json_object_maybe_free() so json_object_put doesn't try to use it as a _delete_parent value.
Update the test_deep_nesting test output.
2026-07-04 11:39:02 -04:00
Eric Hawicz e00697585b Merge pull request #936 from dxbjavid/put-free-outside-assert
free objects outside assert() in json_object_put
2026-07-04 11:20:48 -04:00
Eric Hawicz 3aa996b5b6 Issue #934: Be sure to clear _user_delete in _json_object_put_maybe_free() to avoid calling it twice. Add a test to check. 2026-07-04 11:02:06 -04:00
Javid Khan f291fa81c6 free objects outside assert() in json_object_put 2026-06-30 18:54:06 +05:30
Javid Khan 54f5526011 fix signed overflow negating INT64_MIN in json_object_int_inc 2026-06-27 22:52:43 +05:30
Eric Hawicz b299553de1 Issue #824: start listing releases on github 2026-06-27 10:07:26 -04:00
Eric Hawicz c1c7e50e79 Update the master branch to version 0.19.99 2026-06-27 09:55:42 -04:00
Eric Hawicz c54e6900e7 More updates to ChangeLog for a 0.19 release 2026-06-27 09:35:37 -04:00
Eric Hawicz 3c1cf2b5a4 Merge pull request #931 from dxbjavid/patch-copy-deep-copy
deep copy values in json_patch copy op to avoid aliasing and cycles
2026-06-27 09:11:43 -04:00
Eric Hawicz d2adb47746 Merge pull request #932 from Alb3e3/harden-ci-permissions
ci: set least-privilege GITHUB_TOKEN permissions for meson workflow
2026-06-27 08:44:50 -04:00
Alb3e3 d0cc18738c ci: set least-privilege GITHUB_TOKEN permissions for meson workflow
The meson workflow only builds and tests across platforms; none of its
jobs write to the repository, packages, or other GitHub resources. Add a
workflow-level `permissions: { contents: read }` block so the default
GITHUB_TOKEN follows least privilege instead of inheriting the broad
read/write scopes granted by default.
2026-06-27 13:52:31 +02:00
dxbjavid 5647679c0c deep copy values in json_patch copy op to avoid aliasing and cycles 2026-06-24 21:56:36 +05:30
Eric Hawicz cce075f551 Merge pull request #930 from dxbjavid/get-double-locale-radix
fix locale-dependent strtod in json_object_get_double
2026-06-21 19:46:36 -04:00
Eric Hawicz e1812074fa Issue #928 - work around over-zealous uninitialized check in chromebrew gcc. 2026-06-21 19:25:37 -04:00
Eric Hawicz d9d8cab822 Add tests for the json_parse cli tool. 2026-06-21 13:44:59 -04:00
Eric Hawicz bb9c1238ad Save stderr from test output, allow for non-zero exit code from tests. 2026-06-21 13:43:11 -04:00
Eric Hawicz 1d658982e5 Issue #929: fix bad calculation of error offset when parsing in the apps/json_parse tool.
Also, show the failing character in hex to ensure error output is readable.
2026-06-21 12:43:20 -04:00
dxbjavid c6cd1f236c fix locale-dependent strtod in json_object_get_double 2026-06-15 23:53:53 +05:30
Eric Hawicz d1018cf6ba Update test_object_iterator.expect to match current test output. 2026-05-25 15:27:48 -04:00
Eric Hawicz 3e708e4c4f Drop osx from .travis.yml since macOS builds are no longer supported. 2026-05-24 16:15:19 -04:00