]>
git.proxmox.com Git - mirror_lxc.git/blob - src/tests/fuzz-lxc-define-load.c
1 /* SPDX-License-Identifier: LGPL-2.1+ */
11 int LLVMFuzzerTestOneInput(const uint8_t *data
, size_t size
) {
12 __do_free
char *new_str
= NULL
;
13 struct lxc_container
*c
= NULL
;
14 struct lxc_list defines
;
16 __do_close
int devnull_fd
= -EBADF
;
21 c
= lxc_container_new("FUZZ", NULL
);
22 lxc_test_assert_abort(c
);
24 new_str
= (char *)malloc(size
+1);
25 lxc_test_assert_abort(new_str
);
26 memcpy(new_str
, data
, size
);
29 lxc_list_init(&defines
);
31 if (lxc_config_define_add(&defines
, new_str
) < 0)
34 if (!lxc_config_define_load(&defines
, c
))
37 devnull_fd
= open_devnull();
38 lxc_test_assert_abort(devnull_fd
>= 0);
40 lxc_list_for_each(it
, &defines
) {
41 __do_free
char *val
= NULL
;
42 struct new_config_item
*config_item
= it
->elem
;
45 len
= c
->get_config_item(c
, config_item
->key
, NULL
, 0);
49 val
= (char *)malloc(len
+ 1);
50 lxc_test_assert_abort(val
);
52 if (c
->get_config_item(c
, config_item
->key
, val
, len
+ 1) != len
)
56 dprintf(devnull_fd
, "[%s/%s]\n", config_item
->key
, val
);
61 lxc_config_define_free(&defines
);