]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/fuzz/fuzz-hostname-util.c
Merge pull request #17549 from yuwata/tiny-fixes
[thirdparty/systemd.git] / src / fuzz / fuzz-hostname-util.c
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2
3 #include "alloc-util.h"
4 #include "fd-util.h"
5 #include "fileio.h"
6 #include "fuzz.h"
7 #include "hostname-util.h"
8
9 int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
10 _cleanup_fclose_ FILE *f = NULL;
11 _cleanup_free_ char *ret = NULL;
12
13 if (size == 0)
14 return 0;
15
16 f = fmemopen_unlocked((char*) data, size, "re");
17 assert_se(f);
18
19 /* We don't want to fill the logs with messages about parse errors.
20 * Disable most logging if not running standalone */
21 if (!getenv("SYSTEMD_LOG_LEVEL"))
22 log_set_max_level(LOG_CRIT);
23
24 (void) read_etc_hostname_stream(f, &ret);
25
26 return 0;
27 }