diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-03-21 23:16:56 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-03-22 11:09:52 +0100 |
commit | 9ddd62cda1cda0df88060c236da7652873553419 (patch) | |
tree | c93ad99503416fd4da085d991da6dc89de0edec0 /src/fuzz | |
parent | 8238423095ca54c48d9408a5da13e0325b31e6f6 (diff) | |
download | systemd-9ddd62cda1cda0df88060c236da7652873553419.tar.gz |
fuzz-nspawn-oci: add fuzzer for the oci bundle loader
Diffstat (limited to 'src/fuzz')
-rw-r--r-- | src/fuzz/fuzz-nspawn-oci.c | 28 | ||||
-rw-r--r-- | src/fuzz/meson.build | 5 |
2 files changed, 33 insertions, 0 deletions
diff --git a/src/fuzz/fuzz-nspawn-oci.c b/src/fuzz/fuzz-nspawn-oci.c new file mode 100644 index 0000000000..f7b59f13ba --- /dev/null +++ b/src/fuzz/fuzz-nspawn-oci.c @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: LGPL-2.1+ */ + +#include <errno.h> + +#include "alloc-util.h" +#include "fd-util.h" +#include "fuzz.h" +#include "nspawn-oci.h" + +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { + _cleanup_fclose_ FILE *f = NULL; + _cleanup_(settings_freep) Settings *s = NULL; + + if (size == 0) + return 0; + + f = fmemopen((char*) data, size, "re"); + assert_se(f); + + /* We don't want to fill the logs with messages about parse errors. + * Disable most logging if not running standalone */ + if (!getenv("SYSTEMD_LOG_LEVEL")) + log_set_max_level(LOG_CRIT); + + (void) oci_load(f, "/dev/null", &s); + + return 0; +} diff --git a/src/fuzz/meson.build b/src/fuzz/meson.build index 241fe02edb..0d1ad2b1e1 100644 --- a/src/fuzz/meson.build +++ b/src/fuzz/meson.build @@ -130,6 +130,11 @@ fuzzers += [ libnspawn_core], []], + [['src/fuzz/fuzz-nspawn-oci.c'], + [libshared, + libnspawn_core], + []], + [['src/fuzz/fuzz-calendarspec.c'], [libshared], []], |