Skip to content

Commit 59e53db

Browse files
authored
Validate function section count vs code section count (bytecodealliance#93)
* Update binary.wast tests * Validate function and code section counts * Update version 0.29.2
1 parent 51a9dd9 commit 59e53db

43 files changed

Lines changed: 8 additions & 1 deletion

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "wasmparser"
3-
version = "0.29.1"
3+
version = "0.29.2"
44
authors = ["Yury Delendik <ydelendik@mozilla.com>"]
55
license = "Apache-2.0 WITH LLVM-exception"
66
repository = "https://github.com/yurydelendik/wasmparser.rs"

src/validator.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2111,6 +2111,13 @@ impl<'a> ValidatingParser<'a> {
21112111
}
21122112
}
21132113
ParserState::EndWasm => {
2114+
if self.func_type_indices.len()
2115+
!= self.current_func_index as usize + self.func_imports_count as usize
2116+
{
2117+
self.validation_error = self.create_validation_error(
2118+
"function and code section have inconsistent lengths",
2119+
);
2120+
}
21142121
if let Some(data_count) = self.data_count {
21152122
if data_count != self.data_found {
21162123
self.validation_error = self.create_validation_error(

tests/binary.42.wasm

21 Bytes
Binary file not shown.

tests/binary.43.wasm

22 Bytes
Binary file not shown.

tests/binary.79.wasm

8 Bytes
Binary file not shown.

tests/binary.80.wasm

8 Bytes
Binary file not shown.

tests/invalid/binary.42.wasm

-18 Bytes
Binary file not shown.

tests/invalid/binary.43.wasm

-21 Bytes
Binary file not shown.

tests/invalid/binary.44.wasm

-3 Bytes
Binary file not shown.

tests/invalid/binary.45.wasm

-5 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)