| 1 |
/* SPDX-License-Identifier: LGPL-2.1-or-later */ |
| 2 |
|
| 3 |
#include <unistd.h> |
| 4 |
|
| 5 |
#include "catalog.h" |
| 6 |
#include "fd-util.h" |
| 7 |
#include "fuzz.h" |
| 8 |
#include "hashmap.h" |
| 9 |
#include "tmpfile-util.h" |
| 10 |
|
| 11 |
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { |
| 12 |
_cleanup_(unlink_tempfilep) char name[] = "/tmp/fuzz-catalog.XXXXXX"; |
| 13 |
_cleanup_close_ int fd = -EBADF; |
| 14 |
_cleanup_ordered_hashmap_free_ OrderedHashmap *h = NULL; |
| 15 |
|
| 16 |
fuzz_setup_logging(); |
| 17 |
|
| 18 |
fd = mkostemp_safe(name); |
| 19 |
assert_se(fd >= 0); |
| 20 |
assert_se(write(fd, data, size) == (ssize_t) size); |
| 21 |
|
| 22 |
(void) catalog_import_file(&h, fd, name); |
| 23 |
|
| 24 |
return 0; |
| 25 |
} |