Repository navigation
src: use json_object_from_file/fd instead of read_file/fread_file - #175
Conversation
77b1eef to
db55e13
Compare
|
@jnovy PTAL |
| if (ctx == NULL) | ||
| ctx = (const struct parser_context *) (&tmp_ctx); | ||
|
|
||
| fd = fileno (stream); |
There was a problem hiding this comment.
fileno() returns -1 for FILE* streams created by fmemopen(), open_memstream(), or any other non-fd-backed stream. This breaks libocispec's own fuzzer (src/ocispec/validate.c), which uses fmemopen()
Instead of fileno() + json_object_from_fd(), use fread() in a loop to read the stream contents, then parse with json_tokener_parse()?
There was a problem hiding this comment.
thanks, what do you think of the new version?
There was a problem hiding this comment.
nevermind, it breaks the CI, taking a look...
d9f86fe to
ac0882b
Compare
The gen_json_map_*() functions pass map keys and values directly to strlen() without checking for NULL, causing a SIGSEGV when the fuzzer produces JSON with null values in string maps. Skip entries with NULL keys, and emit json null for NULL string values. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
ac0882b to
70ff818
Compare
|
LGTM I'd add
|
Replace the custom read-file.c/read-file.h (Apache-2.0 licensed) with json-c's json_object_from_file() and json_object_from_fd(), which parse JSON directly from a file path or descriptor without buffering the entire file into memory first. This resolves the license incompatibility with GPL-2.0 consumers like crun (issue containers#174). Closes: containers#174 Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
70ff818 to
6a86d4e
Compare
|
good call! Added |
|
@jnovy OK with the last version? |
|
LGTM |
Replace the custom read-file.c/read-file.h (Apache-2.0 licensed) with json-c's json_object_from_file() and json_object_from_fd(), which parse JSON directly from a file path or descriptor without buffering the entire file into memory first.
This resolves the license incompatibility with GPL-2.0 consumers like crun (issue #174).
Closes: #174