Skip to content

[test] Add index out of range cases - #2353

Merged
rossberg merged 2 commits into
WebAssembly:mainfrom
WasmEdge:test-index-2-32
Nov 26, 2026
Merged

rossberg merged 2 commits into
WebAssembly:mainfrom
WasmEdge:test-index-2-32

Conversation

@ibmibmibm

Copy link
Copy Markdown
Contributor

Adds cases where an index or count of 2^32 or more is malformed: call, br, a struct.get field and an array.new_fixed count. A call index of 2^32-1 parses and fails validation. wabt accepts the call and br cases.

An index is a u32, so an index of 2^32 or more is malformed. Add cases
for call and br. Also add a call with index 2^32-1, which parses but
fails validation, to test the other side of the limit.
The field index of struct.get and the count of array.new_fixed are u32
values, so a value of 2^32 is malformed.
@ibmibmibm
ibmibmibm marked this pull request as ready for review November 25, 2026 23:25
ibmibmibm added a commit to WasmEdge/wabt that referenced this pull request Nov 26, 2026
An index in the text format is a u32. ParseVar parsed the number into a
uint64_t and stored it in a 32-bit Index, so `call 4294967296` became
`call 0` (WebAssembly/spec#2353). ParseVar now parses the number with
ParseInt32, which gives an `invalid int` error for a value over
0xffffffff. On that error the index is kInvalidIndex, so the rejected
number does not resolve to index 0 later in parsing.

Catch::IsCatchAll() still compares the index with kInvalidIndex
(0xffffffff), so `(catch 4294967295)` in a legacy `try` block is read
as `catch_all`. This change does not fix that.
@rossberg
rossberg merged commit f3bbdac into WebAssembly:main Nov 26, 2026
2 checks passed
ibmibmibm added a commit to WasmEdge/wabt that referenced this pull request Nov 26, 2026
An index in the text format is a u32. ParseVar parsed the number into a
uint64_t and stored it in a 32-bit Index, so `call 4294967296` became
`call 0` (WebAssembly/spec#2353). ParseVar now parses the number with
ParseInt32, which gives an `invalid int` error for a value over
0xffffffff. On that error the index is kInvalidIndex, so the rejected
number does not resolve to index 0 later in parsing.

Catch::IsCatchAll() still compares the index with kInvalidIndex
(0xffffffff), so `(catch 4294967295)` in a legacy `try` block is read
as `catch_all`. This change does not fix that.
@ibmibmibm
ibmibmibm deleted the test-index-2-32 branch November 26, 2026 11:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants