Skip to content

Commit 5af9232

Browse files
committed
fuzz: interpreter
1 parent d762e12 commit 5af9232

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

fuzz/fuzz_targets/fuzz_interpreter.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#![no_main]
22

33
use libfuzzer_sys::fuzz_target;
4-
use polkavm::Engine;
54
use polkavm::InterruptKind;
65
use polkavm::ModuleConfig;
76
use polkavm::ProgramBlob;
87
use polkavm::ProgramCounter;
8+
use polkavm::{ArcBytes, Engine};
99

10-
fn harness(_data: &[u8]) {
10+
fn harness(data: &[u8]) {
1111
// configure the polkavm engine
1212
let mut config = polkavm::Config::new();
1313
config.set_backend(Some(polkavm::BackendKind::Interpreter));
@@ -22,10 +22,17 @@ fn harness(_data: &[u8]) {
2222

2323
// create a polkavm program blob (eventually to be filled with the fuzzed data)
2424
let blob = ProgramBlob::default();
25-
blob.code()
25+
26+
let bitmask = vec![0xff; data.len() / 8 + 1];
27+
28+
let fuzzed_blob = ProgramBlob {
29+
code: data.into(),
30+
bitmask: bitmask.into(),
31+
..blob
32+
};
2633

2734
// create a polkavm module from the engine, module config, and program blob
28-
let module = polkavm::Module::from_blob(&engine, &module_config, blob).unwrap();
35+
let module = polkavm::Module::from_blob(&engine, &module_config, fuzzed_blob).unwrap();
2936

3037
let initial_pc = ProgramCounter(0);
3138
let mut final_pc = initial_pc;

0 commit comments

Comments
 (0)