Debian Codegraph @

src/boot/fuzz-bcd.c

raw
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2
3 #include "alloc-util.h"
4 #include "bcd.h"
5 #include "fuzz.h"
6 #include "utf8.h"
7
8 int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
9 _cleanup_free_ void *p = NULL;
10
11 /* This limit was borrowed from src/boot/efi/boot.c */
12 if (outside_size_range(size, 0, 100*1024))
13 return 0;
14
15 fuzz_setup_logging();
16
17 p = memdup(data, size);
18 assert_se(p);
19
20 char16_t *title = get_bcd_title(p, size);
21 /* If we get something, it must be NUL-terminated, but an empty string is still valid! */
22 DO_NOT_OPTIMIZE(title && char16_strlen(title));
23 return 0;
24 }