1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 
3 #include "alloc-util.h"
4 #include "fd-util.h"
5 #include "fuzz.h"
6 #include "hostname-setup.h"
7 
LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)8 int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
9         _cleanup_fclose_ FILE *f = NULL;
10         _cleanup_free_ char *ret = NULL;
11 
12         f = data_to_file(data, size);
13         assert_se(f);
14 
15         /* We don't want to fill the logs with messages about parse errors.
16          * Disable most logging if not running standalone */
17         if (!getenv("SYSTEMD_LOG_LEVEL"))
18                 log_set_max_level(LOG_CRIT);
19 
20         (void) read_etc_hostname_stream(f, &ret);
21 
22         return 0;
23 }
24