Commit Graph

1100 Commits

Author SHA1 Message Date
Eric Hawicz
cf30cba4ac Merge pull request #657 from stoeckmann/getrandom
Use GRND_NONBLOCK with getrandom.
2020-08-15 15:01:41 -04:00
Tobias Stoeckmann
f052e42f56 Use GRND_NONBLOCK with getrandom.
The json-c library is used in cryptsetup for LUKS2 header information.
Since cryptsetup can be called very early during boot, the developers
avoid getrandom() calls in their own code base for now. [1]

Introducing a blocking getrandom() call in json-c therefore introduces
this issue for cryptsetup as well. Even though cryptsetup issues do not
have to be json-c issues, here is my proposal:

Let's use a non-blocking call, falling back to other sources if the call
would block. Since getrandom() accesses urandom, it must mean that we
are in an early boot phase -- otherwise the call would not block
according to its manual page.

As stated in manual page of random(4), accessing /dev/urandom won't
block but return weak random numbers, therefore this fallback would work
for json-c.

While at it, fixed the debug message.

[1] https://gitlab.com/cryptsetup/cryptsetup/-/merge_requests/47
    which references to https://lwn.net/Articles/800509/
2020-08-15 15:52:17 +02:00
Eric Hawicz
104b408ee8 Merge pull request #656 from pogaram/fix-warnings
Fixed warnings
2020-08-14 16:57:32 -04:00
Aram Poghosyan
0ffb384409 Fixed warnings 2020-08-14 11:45:33 +04:00
Eric Hawicz
98b7ee93fd Merge pull request #655 from MarcT512/issue654
json_parse: Fix read past end of buffer
2020-08-07 10:18:30 -04:00
Marc
4e9e44e525 Fix read past end of buffer
Resolves https://github.com/json-c/json-c/issues/654
2020-08-07 10:49:45 +01:00
Eric Hawicz
56a89f902f Merge pull request #653 from lamby/966657-json-c-please-make-the-build-reproducible
Make the documentation build reproducibly
2020-08-01 22:06:38 -04:00
Chris Lamb
46eea84554 Make the documentation build reproducibly
Whilst working on the Reproducible Builds effort [0] I noticed that
json-c could not be built reproducibly.

This is because it used the full, absolute path name as an (sanitised)
input to a filename, resulting in some binary package containing, for
example:

  /usr/share/doc/libjson-c-dev/html/md__build_1st_json-c-0_815_issues_closed_for_0_813.html
                                        ^^^^^^^^^^^^^^^^^^^^^^
or

  /usr/share/doc/libjson-c-dev/html/md__build_2_json-c-0_815_2nd_issues_closed_for_0_813.html
                                        ^^^^^^^^^^^^^^^^^^^^^^^^

These differing values are based on the path in which json-c is built. This was
originally filed in Debian as #966657 [1].

 [0] https://reproducible-builds.org/
 [1] https://bugs.debian.org/966657
2020-08-01 11:26:55 +01:00
Eric Hawicz
88cce7b9c5 Merge pull request #651 from alanc/getrandom
Getrandom
2020-07-31 20:30:11 -04:00
Alan Coopersmith
6cf4847796 Use getrandom() if available in json_c_get_random_seed
Lower overhead than opening & reading from /dev/urandom, and works
in chroots and other situtations where /dev/urandom is not available.
Falls back to existing methods when kernel doesn't support the syscall.
2020-07-31 08:28:07 -07:00
Eric Haszlakiewicz
002411293d Issue #649: Drop the generated doc/Doxyfile when creating a release. 2020-07-28 03:52:22 +00:00
Eric Hawicz
66f8ca3c03 Merge pull request #650 from sartura/readme-update
README: fix spelling errors
2020-07-27 10:31:05 -04:00
Jakov Smolic
55bf2d365d README: fix spelling errors
Signed-off-by: Jakov Smolic <jakov.smolic@sartura.hr>
2020-07-27 15:05:55 +02:00
Eric Haszlakiewicz
47189b5ff1 Include updating the json-c-current-releaes gh-pages symlink as part of the release process. 2020-07-26 15:51:07 +00:00
Eric Haszlakiewicz
de02d09c32 Update the master branch to version 0.15.99 2020-07-26 15:26:53 +00:00
Eric Haszlakiewicz
870965e1ea Update AUTHORS, add issues_closed_for_0.15.md, tweak the release checklist slightly. 2020-07-24 03:17:13 +00:00
Eric Hawicz
616b1050b2 Merge pull request #648 from MarcT512/rbf
Fix "may be used uninitialized" Release build failure
2020-07-23 22:26:58 -04:00
Marc
4a23d3413d Fix "may be used uninitialized" Release build failure
Fixes https://github.com/json-c/json-c/issues/647
2020-07-23 18:19:12 +01:00
Eric Haszlakiewicz
730e3d044f Issue #594 - provide an OVERRIDE_GET_RANDOM_SEED cmake variable to override json_c_get_random_seed() for embedded platforms where time(NULL) doesn't work.
Example:
mkdir build && cd build
cmake -DOVERRIDE_GET_RANDOM_SEED='do { extern uint32_t getMsTicks(void); int ms = getMsTicks() * 433494437; return ms; } while(0)' ..
2020-07-22 02:25:03 +00:00
Eric Hawicz
64de4b6e9f Merge pull request #646 from pascal-cuoq/fix_645
Cast to unsigned char instead of int when calling tolower (Fixes #645)
2020-07-21 21:24:59 -04:00
Pascal Cuoq
1962ba7de3 Fixes #645 2020-07-21 17:54:26 +02:00
Eric Haszlakiewicz
024e835f4c Update the ChangeLog with recent changes, in preparation for a 0.15 release. 2020-07-20 03:39:01 +00:00
Eric Haszlakiewicz
78a0f2ea5d Remove the obsolete config.h.win32 2020-07-17 03:47:28 +00:00
Eric Haszlakiewicz
e46b9cdb7d Fix a number of things with the generated docs, including translating triple-backtick code blocks into a form doxygen understands. 2020-07-17 03:46:21 +00:00
Eric Haszlakiewicz
9a7de35b92 Add some more detail about how to use json-c in README.md. 2020-07-17 03:42:38 +00:00
Eric Haszlakiewicz
cb10a13e94 Remove the THIS_FUNCTION_IS_DEPRECATED define, we stopped using it long ago. 2020-07-17 03:20:29 +00:00
Eric Haszlakiewicz
2508109b18 Remove the obsolete README.json_object-split.md, and mark README.md as being the doxygen mainpage. 2020-07-12 19:16:19 +00:00
Eric Haszlakiewicz
4d9f6dd22e Issue #642: improve the docs for json_object_put() and json_object_get(). 2020-07-12 18:43:27 +00:00
Eric Haszlakiewicz
2330c6f0de Expand the doc for json_object_array_get_idx() to explain that it does not adjust refcounts. 2020-07-12 17:55:46 +00:00
Eric Haszlakiewicz
6542d33cd1 Issue #641: Add a cast to void * to address some theoretically undefined printf behavior. 2020-07-11 15:03:00 +00:00
Eric Haszlakiewicz
10a9ac245e Issue #642: improve docs for json_tokener.h and json_object_object_add(). 2020-07-11 04:04:58 +00:00
Eric Haszlakiewicz
6fa8b7ff42 Don't export json-c symbols starting with an underscore, put deprecated exports into a "JSONC_PRIVATE" version, and note stuff to do during releases.
See also PR #639 and issue #621
2020-07-04 19:00:10 +00:00
Eric Haszlakiewicz
6068d3f6d1 Change the strerror_override handling to check $_JSON_C_STRERROR_OVERRIDE instead of using a variable, so we don't need to export it. 2020-07-04 18:58:00 +00:00
Eric Hawicz
b01d50b8dc Merge pull request #639 from smcv/symbol-versions
build: Add a symbol version to all exported symbols
2020-07-04 14:26:20 -04:00
Simon McVittie
c2c94024f5 build: Add symbol versions to all exported symbols
With this version script, newly-linked binaries that depend on the
json-c shared library will refer to its symbols in a versioned form,
preventing their references from being resolved to a symbol of the same
name exported by json-glib or libjansson if those libraries appear in
dependency search order before json-c, which will usually result in
a crash. This is necessary because ELF symbol resolution normally uses
a single flat namespace, not a tree like Windows symbol resolution.
At least one symbol (json_object_iter_next()) is exported by all three
JSON libraries.

Linking with -Bsymbolic is not enough to have this effect in all cases,
because -Bsymbolic only affects symbol lookup within a shared object,
for example when json_object_set_serializer() calls
json_object_set_userdata(). It does not affect calls from external
code into json-c, unless json-c was statically linked into the
external caller.

This change will also not prevent code that depends on json-glib or
libjansson from finding json-c's symbols and crashing; to prevent
that, a corresponding change in json-glib or libjansson would be needed.

Adding a symbol-version is a backwards-compatible change, but once
added, removing or changing the symbol-version on a symbol would be an
incompatible change that requires a SONAME bump.

Resolves: https://github.com/json-c/json-c/issues/621
(when combined with an equivalent change to libjansson).

Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-07-01 18:24:26 +01:00
Eric Haszlakiewicz
6465e74020 Use constants referring to the signed integer types when setting SSIZE_T_MAX.
In practice, the sizes of the signed and unsigned integer types will
almost cetainly be the same, but this is more correct.
Pointed out in issue #638.
2020-07-01 00:34:46 +00:00
Eric Haszlakiewicz
34334e5d3f Replace one call to json_object_new_array() with json_object_new_array_ext() to ensure it at least minimally works. 2020-06-29 02:35:26 +00:00
Eric Haszlakiewicz
0b67caec1a Add doc comment for json_object_new_array_ext(). 2020-06-29 02:31:32 +00:00
Eric Haszlakiewicz
a4e3700972 Fix code formatting 2020-06-29 02:31:18 +00:00
Eric Haszlakiewicz
5f3bf70f03 Make sure TEST_PARSE_CHUNKSIZE is valid if it's set. 2020-06-29 02:18:34 +00:00
Eric Haszlakiewicz
f23486a321 In the json_tokener_state_number case, explicitly adjust what "number" characters are allowed based on the exact micro-state that we're in, and check for invalid following characters in a different way, to allow a valid json_type_number object to be returned at the top level.
This causes previously failing strings like "123-456" to return a valid json_object with the appropriate value.  If you care about the trailing content, call json_tokener_parse_ex() and check the parse end point with json_tokener_get_parse_end().
2020-06-29 02:14:26 +00:00
Eric Haszlakiewicz
6eac6986c9 Fix incremental parsing of invalid numbers with exponents, such as "0e+-" and "12.3E12E12", while still allowing "0e+" in non-strict mode.
Deprecate the json_parse_double() function from json_util.h
2020-06-27 15:35:04 +00:00
Eric Haszlakiewicz
84e6032883 Issue #635: Fix "expression has no effect" warning in json_tokener.c by casting to void. 2020-06-23 02:51:46 +00:00
Eric Haszlakiewicz
7a72805e34 Fix memory leak in test_parse's single_incremental_parse(). 2020-06-22 01:12:03 +00:00
Eric Haszlakiewicz
7d3c2d9fad Drop extra blank lines from arraylist.h 2020-06-21 18:30:40 +00:00
Eric Haszlakiewicz
a68566bf6a Issue #616: Change the parsing of surrogate pairs in unicode escapes so it uses a couple of additional states instead of assuming the low surrogate is already present, to ensure that we correctly handle various cases of incremental parsing. 2020-06-21 18:29:57 +00:00
Eric Haszlakiewicz
197e372464 In test_parse, fix lengths passed during a couple of incremental tests.
Add an optional way to use an incremental chunk size ($TEST_PARSE_CHUNKSIZE)
for all of the single_basic_parse tests, in additional to the regular way.
2020-06-21 17:36:38 +00:00
Eric Haszlakiewicz
36118b681e Rearrange the json_tokener_state_escape_unicode case in json_tokener to simplify the code slightly and make it a bit easier to understand.
While here, drop the utf8_replacement_char that is unnecesarily added if we run out of input in the middle of a unicode escape.  No other functional changes (yet).
2020-06-21 03:10:55 +00:00
Eric Haszlakiewicz
50179fb09f Update the json_tokener_parse_ex() docs to clarify that the final '\0' character is to be included in length passed in. 2020-06-21 02:35:42 +00:00
Eric Hawicz
da76ee26e7 Merge pull request #633 from dota17/issue616
fix issue 616: support the surrogate pair in split file.
2020-06-20 22:33:17 -04:00