]>
Commit | Line | Data |
---|---|---|
dec64820 EV |
1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
2 | ||
3 | #include <stddef.h> | |
4 | #include <stdint.h> | |
5 | ||
6 | #include "conf.h" | |
7 | #include "confile.h" | |
8 | #include "lxctest.h" | |
9 | #include "utils.h" | |
10 | ||
11 | int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { | |
12 | int fd = -1; | |
f329f022 | 13 | char tmpf[] = "/tmp/fuzz-lxc-config-read-XXXXXX"; |
dec64820 EV |
14 | struct lxc_conf *conf = NULL; |
15 | ||
e7e0343f EV |
16 | /* |
17 | * 100Kb should probably be enough to trigger all the issues | |
18 | * we're interested in without any timeouts | |
19 | */ | |
20 | if (size > 102400) | |
21 | return 0; | |
22 | ||
dec64820 EV |
23 | fd = lxc_make_tmpfile(tmpf, false); |
24 | lxc_test_assert_abort(fd >= 0); | |
25 | lxc_write_nointr(fd, data, size); | |
26 | close(fd); | |
27 | ||
28 | conf = lxc_conf_init(); | |
29 | lxc_test_assert_abort(conf); | |
30 | lxc_config_read(tmpf, conf, false); | |
31 | lxc_conf_free(conf); | |
32 | ||
33 | (void) unlink(tmpf); | |
34 | return 0; | |
35 | } |