diff --git a/src/boot/efi/fuzz-bcd.c b/src/boot/efi/fuzz-bcd.c index 6d76533e8f..297b71f60c 100644 --- a/src/boot/efi/fuzz-bcd.c +++ b/src/boot/efi/fuzz-bcd.c @@ -2,7 +2,6 @@ #include "alloc-util.h" #include "bcd.h" -#include "fd-util.h" #include "fuzz.h" #include "utf8.h" @@ -13,14 +12,11 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { if (outside_size_range(size, 0, 100*1024)) return 0; - if (!getenv("SYSTEMD_LOG_LEVEL")) - log_set_max_level(LOG_CRIT); - p = memdup(data, size); assert_se(p); char16_t *title = get_bcd_title(p, size); - if (title) - (void) char16_strlen(title); + /* If we get something, it must be NUL-terminated, but an empty string is still valid! */ + DO_NOT_OPTIMIZE(title && char16_strlen(title)); return 0; } diff --git a/src/fuzz/fuzz.h b/src/fuzz/fuzz.h index 04c438edaf..a7d3a89fe2 100644 --- a/src/fuzz/fuzz.h +++ b/src/fuzz/fuzz.h @@ -27,3 +27,6 @@ static inline bool outside_size_range(size_t size, size_t lower, size_t upper) { return FUZZ_USE_SIZE_LIMIT; return false; } + +/* Force value to not be optimized away. */ +#define DO_NOT_OPTIMIZE(value) ({ asm volatile("" : : "g"(value) : "memory"); })