diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-10 20:49:52 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-10 20:49:52 +0000 |
commit | 55944e5e40b1be2afc4855d8d2baf4b73d1876b5 (patch) | |
tree | 33f869f55a1b149e9b7c2b7e201867ca5dd52992 /src/boot/efi/fuzz-efi-osrel.c | |
parent | Initial commit. (diff) | |
download | systemd-55944e5e40b1be2afc4855d8d2baf4b73d1876b5.tar.xz systemd-55944e5e40b1be2afc4855d8d2baf4b73d1876b5.zip |
Adding upstream version 255.4.upstream/255.4
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boot/efi/fuzz-efi-osrel.c')
-rw-r--r-- | src/boot/efi/fuzz-efi-osrel.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/boot/efi/fuzz-efi-osrel.c b/src/boot/efi/fuzz-efi-osrel.c new file mode 100644 index 0000000..1a5a9bc --- /dev/null +++ b/src/boot/efi/fuzz-efi-osrel.c @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ + +#include "alloc-util.h" +#include "efi-string.h" +#include "fuzz.h" + +#define SEP_LEN 4 + +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { + if (outside_size_range(size, SEP_LEN + 1, 64 * 1024)) + return 0; + if (data[SEP_LEN] != '\0') + return 0; + + fuzz_setup_logging(); + + _cleanup_free_ char *p = memdup_suffix0(data + SEP_LEN + 1, size - SEP_LEN - 1); + assert_se(p); + + size_t pos = 0; + char *key, *value; + while (line_get_key_value(p, (const char *) data, &pos, &key, &value)) { + assert_se(key); + assert_se(value); + } + + return 0; +} |