]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/fuzz/fuzz-catalog.c
Merge pull request #13439 from yuwata/core-support-systemctl-clean-more
[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;
a95686bb 12 _cleanup_ordered_hashmap_free_free_free_ OrderedHashmap *h = NULL;
4928e8ad
EV
13
14 if (!getenv("SYSTEMD_LOG_LEVEL"))
15 log_set_max_level(LOG_CRIT);
16
a95686bb 17 assert_se(h = ordered_hashmap_new(&catalog_hash_ops));
4928e8ad
EV
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}