Commit a686de07 authored by ahaas's avatar ahaas Committed by Commit bot

[wasm] Add the 'end' opcode at the end of the fuzzer input

Without the end opcode at the end of a function nearly every fuzzer
input would be invalid and test nothing.

R=titzer@chromium.org

Review-Url: https://codereview.chromium.org/2634943002
Cr-Commit-Position: refs/heads/master@{#42363}
parent b5b56e92
...@@ -114,6 +114,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { ...@@ -114,6 +114,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
builder.AddFunction(sig_builder.Build()); builder.AddFunction(sig_builder.Build());
uint32_t code_size = static_cast<uint32_t>(size / num_functions); uint32_t code_size = static_cast<uint32_t>(size / num_functions);
f->EmitCode(data, code_size); f->EmitCode(data, code_size);
uint8_t end_opcode = kExprEnd;
f->EmitCode(&end_opcode, 1);
data += code_size; data += code_size;
size -= code_size; size -= code_size;
if (fun == 0) { if (fun == 0) {
......
...@@ -68,6 +68,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { ...@@ -68,6 +68,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
v8::internal::wasm::WasmFunctionBuilder* f = v8::internal::wasm::WasmFunctionBuilder* f =
builder.AddFunction(sigs.i_iii()); builder.AddFunction(sigs.i_iii());
f->EmitCode(data, static_cast<uint32_t>(size)); f->EmitCode(data, static_cast<uint32_t>(size));
uint8_t end_opcode = kExprEnd;
f->EmitCode(&end_opcode, 1);
f->ExportAs(v8::internal::CStrVector("main")); f->ExportAs(v8::internal::CStrVector("main"));
ZoneBuffer buffer(&zone); ZoneBuffer buffer(&zone);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment