Skip to content

Commit

Permalink
Make the raw fuzzing target assert deterministic serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
fitzgen committed Sep 4, 2019
1 parent b8ce4a1 commit e79b0de
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion fuzz/fuzz_targets/raw.rs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,16 @@
extern crate libfuzzer_sys;

fuzz_target!(|data: &[u8]| {
let _ = walrus::Module::from_buffer(data);
let module = match walrus::Module::from_buffer(data) {
Ok(m) => m,
Err(_) => return,
};
let serialized = module.emit_wasm();
let module =
walrus::Module::from_buffer(&serialized).expect("we should only emit valid Wasm data");
let reserialized = module.emit_wasm();
assert_eq!(
serialized, reserialized,
"emitting wasm should be deterministic"
);
});

0 comments on commit e79b0de

Please sign in to comment.