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