diff --git a/fuzzers/tint_common_fuzzer.cc b/fuzzers/tint_common_fuzzer.cc index 88f0107dcf..590ff15dec 100644 --- a/fuzzers/tint_common_fuzzer.cc +++ b/fuzzers/tint_common_fuzzer.cc @@ -205,8 +205,8 @@ int CommonFuzzer::Run(const uint8_t* data, size_t size) { // sizeof(uint32_t)` uint32_t values. If `size` is not a multiple of // sizeof(uint32_t) then not all of `data` can be copied into // `spirv_input`, and any trailing bytes are discarded. - const size_t adjusted_size = (size / sizeof(uint32_t)) * sizeof(uint32_t); - std::memcpy(spirv_input.data(), data, adjusted_size); + std::memcpy(spirv_input.data(), data, + spirv_input.size() * sizeof(uint32_t)); if (spirv_input.empty()) { return 0; } diff --git a/fuzzers/tint_spirv_tools_fuzzer/fuzzer.cc b/fuzzers/tint_spirv_tools_fuzzer/fuzzer.cc index dac05dc918..6ca8b46fde 100644 --- a/fuzzers/tint_spirv_tools_fuzzer/fuzzer.cc +++ b/fuzzers/tint_spirv_tools_fuzzer/fuzzer.cc @@ -102,7 +102,8 @@ extern "C" size_t LLVMFuzzerCustomMutator(uint8_t* data, unsigned seed) { assert((size % 4) == 0 && "A valid SPIR-V binary's size must be a multiple of 4, and the " - "SPIR-V Tools fuzzer should only work with valid binaries."); + "SPIR-V Tools fuzzer should only work with valid binaries. Check that " + "the fuzzer has been correctly configured."); std::vector binary(size / sizeof(uint32_t)); std::memcpy(binary.data(), data, size); @@ -175,8 +176,10 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { } assert((size % 4) == 0 && - "A valid SPIR-V binary's size is a multiple of 4 bytes, and the " - "SPIR-V Tools fuzzer should only work with valid binaries."); + "By design, the SPIR-V Tools fuzzer should only ever test using valid " + "SPIR-V binaries, whose sizes should be multiples of 4 bytes. Check " + "that the fuzzer has been configured correctly, with a corpus of " + "valid SPIR-V binaries, and with only the custom mutator enabled."); CommonFuzzer spv_to_wgsl(InputFormat::kSpv, OutputFormat::kWGSL); spv_to_wgsl.EnableInspector();