summaryrefslogtreecommitdiff
path: root/src/fuzz/fuzz-json.c
diff options
context:
space:
mode:
authorEvgeny Vereshchagin <evvers@ya.ru>2022-01-03 12:31:07 +0000
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2022-01-04 09:26:26 +0100
commit5df66d7d68006615abb4c4d3b1ebad545af4dd72 (patch)
tree9eb17e7d3061239c8eef09d2af49984dc1c1beb1 /src/fuzz/fuzz-json.c
parentbb18c742c8131c41d1152eb387e82d788874306b (diff)
downloadsystemd-5df66d7d68006615abb4c4d3b1ebad545af4dd72.tar.gz
fuzz: no longer skip empty files
Empty files and empty strings seem to have triggered various issues in the past so it seems they shouldn't be ignore by the fuzzers just because fmemopen can't handle them. Prompted by https://github.com/systemd/systemd/pull/21939#issuecomment-1003113669
Diffstat (limited to 'src/fuzz/fuzz-json.c')
-rw-r--r--src/fuzz/fuzz-json.c6
1 files changed, 1 insertions, 5 deletions
diff --git a/src/fuzz/fuzz-json.c b/src/fuzz/fuzz-json.c
index f9a0e818c4..ad7460c6fd 100644
--- a/src/fuzz/fuzz-json.c
+++ b/src/fuzz/fuzz-json.c
@@ -1,7 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "alloc-util.h"
-#include "fileio.h"
#include "fd-util.h"
#include "fuzz.h"
#include "json.h"
@@ -12,10 +11,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
_cleanup_fclose_ FILE *f = NULL, *g = NULL;
_cleanup_(json_variant_unrefp) JsonVariant *v = NULL;
- if (size == 0)
- return 0;
-
- f = fmemopen_unlocked((char*) data, size, "re");
+ f = data_to_file(data, size);
assert_se(f);
if (json_parse_file(f, NULL, 0, &v, NULL, NULL) < 0)