File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ wasmparser = { path = "../crates/wasmparser" }
1616wasmprinter = { path = " ../crates/wasmprinter" }
1717wast = { path = " ../crates/wast" }
1818wat = { path = " ../crates/wat" }
19+ wasm-smith = " 0.1.0"
1920
2021[[bin ]]
2122name = " text-lexer"
@@ -46,3 +47,9 @@ test = false
4647name = " incremental-parse"
4748path = " fuzz_targets/incremental-parse.rs"
4849test = false
50+
51+ [[bin ]]
52+ name = " validate-valid-module"
53+ path = " fuzz_targets/validate-valid-module.rs"
54+ test = false
55+ doc = false
Original file line number Diff line number Diff line change 1+ #![ no_main]
2+
3+ use libfuzzer_sys:: fuzz_target;
4+ use wasm_smith:: Module ;
5+
6+ // Define a fuzz target that accepts arbitrary
7+ // `Module`s as input.
8+ fuzz_target ! ( |m: Module | {
9+ // Convert the module into Wasm bytes.
10+ let bytes = m. to_bytes( ) ;
11+
12+ // Validate the module and assert that it passes
13+ // validation.
14+ let mut validator = wasmparser:: Validator :: new( ) ;
15+ validator. wasm_features( wasmparser:: WasmFeatures {
16+ multi_value: true ,
17+ ..wasmparser:: WasmFeatures :: default ( )
18+ } ) ;
19+ if let Err ( e) = validator. validate_all( & bytes) {
20+ std:: fs:: write( "test.wasm" , bytes) . unwrap( ) ;
21+ panic!( "Invalid module: {}" , e) ;
22+ }
23+ } ) ;
You can’t perform that action at this time.
0 commit comments