]> git.proxmox.com Git - mirror_lxc.git/blob - src/tests/fuzz-lxc-config-read.c
tests: include config.h
[mirror_lxc.git] / src / tests / fuzz-lxc-config-read.c
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2
3 #include "config.h"
4
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;
15 char tmpf[] = "/tmp/fuzz-lxc-config-read-XXXXXX";
16 struct lxc_conf *conf = NULL;
17
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
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 }