From 55944e5e40b1be2afc4855d8d2baf4b73d1876b5 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 10 Apr 2024 22:49:52 +0200 Subject: Adding upstream version 255.4. Signed-off-by: Daniel Baumann --- src/boot/efi/fuzz-efi-osrel.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/boot/efi/fuzz-efi-osrel.c (limited to 'src/boot/efi/fuzz-efi-osrel.c') 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; +} -- cgit v1.2.3