]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/fuzz/fuzz-nspawn-oci.c
Add fmemopen_unlocked() and use unlocked ops in fuzzers and some other tests
[thirdparty/systemd.git] / src / fuzz / fuzz-nspawn-oci.c
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2
3 #include "alloc-util.h"
4 #include "fd-util.h"
5 #include "fileio.h"
6 #include "fuzz.h"
7 #include "nspawn-oci.h"
8
9 int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
10 _cleanup_fclose_ FILE *f = NULL;
11 _cleanup_(settings_freep) Settings *s = NULL;
12
13 if (size == 0)
14 return 0;
15
16 f = fmemopen_unlocked((char*) data, size, "re");
17 assert_se(f);
18
19 /* We don't want to fill the logs with messages about parse errors.
20 * Disable most logging if not running standalone */
21 if (!getenv("SYSTEMD_LOG_LEVEL"))
22 log_set_max_level(LOG_CRIT);
23
24 (void) oci_load(f, "/dev/null", &s);
25
26 return 0;
27 }