Skip to content

Commit

Permalink
fuzz: Add fuzzer for efi conf/osrel parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
medhefgo committed Oct 15, 2023
1 parent 5ce851a commit e9e4086
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/boot/efi/fuzz-efi-osrel.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* 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;

_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;
}
3 changes: 3 additions & 0 deletions src/boot/efi/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ executables += [
efi_fuzz_template + {
'sources' : files('fuzz-efi-string.c'),
},
efi_fuzz_template + {
'sources' : files('fuzz-efi-osrel.c'),
},
efi_fuzz_template + {
'sources' : files('fuzz-efi-printf.c'),
},
Expand Down

0 comments on commit e9e4086

Please sign in to comment.