Skip to content

Commit

Permalink
Raise imports and exports limit to 1,000,000
Browse files Browse the repository at this point in the history
  • Loading branch information
fitzgen committed Jul 16, 2024
1 parent a4c4021 commit b3a54b1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
3 changes: 2 additions & 1 deletion crates/wasmparser/src/limits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
pub const MAX_WASM_TYPES: usize = 1_000_000;
pub const MAX_WASM_SUPERTYPES: usize = 1;
pub const MAX_WASM_FUNCTIONS: usize = 1_000_000;
pub const MAX_WASM_EXPORTS: usize = 100_000;
pub const MAX_WASM_IMPORTS: usize = 1_000_000;
pub const MAX_WASM_EXPORTS: usize = 1_000_000;
pub const MAX_WASM_GLOBALS: usize = 1_000_000;
pub const MAX_WASM_ELEMENT_SEGMENTS: usize = 100_000;
pub const MAX_WASM_DATA_SEGMENTS: usize = 100_000;
Expand Down
12 changes: 11 additions & 1 deletion crates/wasmparser/src/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,17 @@ impl Validator {
Order::Import,
section,
"import",
|_, _, _, _, _| Ok(()), // add_import will check limits
|state, _, _, count, offset| {
check_max(
state.module.imports.len(),
count,
MAX_WASM_IMPORTS,
"imports",
offset,
)?;
state.module.assert_mut().imports.reserve(count as usize);
Ok(())
},
|state, features, types, import, offset| {
state
.module
Expand Down

0 comments on commit b3a54b1

Please sign in to comment.