Skip to content

Commit 1ed898a

Browse files
authored
Fix fuzzing with stream<char> (#2446)
Fallout from #2437 in fuzzing where it needs to not be generated any more.
1 parent e48300e commit 1ed898a

3 files changed

Lines changed: 16 additions & 1 deletion

File tree

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/wit-smith/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ log = { workspace = true }
1919
semver = { workspace = true }
2020
wit-component = { workspace = true }
2121
wit-parser = { workspace = true }
22+
wasmparser = { workspace = true }

crates/wit-smith/src/lib.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,18 @@ pub fn smith(config: &Config, u: &mut Unstructured<'_>) -> Result<Vec<u8>> {
4242
}
4343
let pkg = last.unwrap();
4444

45-
Ok(wit_component::encode(&resolve, pkg).expect("failed to encode WIT document"))
45+
let wasm = wit_component::encode(&resolve, pkg).expect("failed to encode WIT document");
46+
47+
// Handle disallowing `stream<char>` here vs not generating it to start
48+
// with as it's a bit easier to handle.
49+
if let Err(e) = wasmparser::Validator::new_with_features(wasmparser::WasmFeatures::all())
50+
.validate_all(&wasm)
51+
{
52+
if e.to_string()
53+
.contains("`stream<char>` is not valid at this time")
54+
{
55+
return Err(arbitrary::Error::IncorrectFormat);
56+
}
57+
}
58+
Ok(wasm)
4659
}

0 commit comments

Comments
 (0)