]>
Commit | Line | Data |
---|---|---|
db9ecf05 | 1 | /* SPDX-License-Identifier: LGPL-2.1-or-later */ |
212bd73c EV |
2 | |
3 | #include "fd-util.h" | |
212bd73c EV |
4 | #include "fs-util.h" |
5 | #include "fuzz.h" | |
6 | #include "networkd-manager.h" | |
e4de7287 | 7 | #include "tmpfile-util.h" |
212bd73c EV |
8 | |
9 | int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { | |
10 | _cleanup_(manager_freep) Manager *manager = NULL; | |
11 | _cleanup_fclose_ FILE *f = NULL; | |
12 | _cleanup_(unlink_tempfilep) char network_config[] = "/tmp/fuzz-networkd.XXXXXX"; | |
13 | ||
0fb72928 ZJS |
14 | if (size > 65535) |
15 | return 0; | |
16 | ||
95ccf1aa EV |
17 | if (!getenv("SYSTEMD_LOG_LEVEL")) |
18 | log_set_max_level(LOG_CRIT); | |
19 | ||
212bd73c EV |
20 | assert_se(fmkostemp_safe(network_config, "r+", &f) == 0); |
21 | if (size != 0) | |
22 | assert_se(fwrite(data, size, 1, f) == 1); | |
23 | ||
7cd1f60d | 24 | fflush(f); |
212bd73c | 25 | assert_se(manager_new(&manager) >= 0); |
7f06b3e1 | 26 | (void) network_load_one(manager, &manager->networks, network_config); |
212bd73c EV |
27 | return 0; |
28 | } |