Commit 3f4960a
authored
This commit fixes a mistake that was introduced in #1587 which was first
released as 1.210.0 as part of `wasm-tools`. In #1587 control flow was
restructured in the validator to expose an out-of-bounds access of
`self.control` when a function has instructions after the final `end`
instruction. The fix in this commit is to apply the same logic as
`check_return` which is to explicitly check for the length of the
`control` stack and return an error.
This bug comes from how instructions-after-`end` are detected in the
validator. Notably this erroneous condition is checked when the
functions reaches EOF, not when the control stack is emptied. This is to
avoid checking at all instructions that the control stack has a length
greater than one and to instead defer that check to only instructions
that need it. This susprising behavior, though, ended up leading to this
bug.
1 parent 8c43f94 commit 3f4960a
File tree
3 files changed
+23
-0
lines changed- crates/wasmparser/src/validator
- tests
- local
- snapshots/local
3 files changed
+23
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
904 | 904 | | |
905 | 905 | | |
906 | 906 | | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
907 | 910 | | |
908 | 911 | | |
909 | 912 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
0 commit comments