]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/fuzz/fuzz-catalog.c
Merge pull request #11041 from yuwata/update-missing-v2
[thirdparty/systemd.git] / src / fuzz / fuzz-catalog.c
CommitLineData
4928e8ad
EV
1/* SPDX-License-Identifier: LGPL-2.1+ */
2
3#include "catalog.h"
4#include "fd-util.h"
4928e8ad
EV
5#include "fs-util.h"
6#include "fuzz.h"
e4de7287 7#include "tmpfile-util.h"
4928e8ad
EV
8
9int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
10 _cleanup_(unlink_tempfilep) char name[] = "/tmp/fuzz-catalog.XXXXXX";
11 _cleanup_close_ int fd = -1;
12 _cleanup_hashmap_free_free_free_ Hashmap *h = NULL;
13
14 if (!getenv("SYSTEMD_LOG_LEVEL"))
15 log_set_max_level(LOG_CRIT);
16
17 assert_se(h = hashmap_new(&catalog_hash_ops));
18
19 fd = mkostemp_safe(name);
20 assert_se(fd >= 0);
21 assert_se(write(fd, data, size) == (ssize_t) size);
22
23 (void) catalog_import_file(h, name);
24
25 return 0;
26}