Repository navigation
[test] Add index out of range cases - #2353
Merged
Merged
Conversation
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
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
approved these changes
Nov 26, 2026
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds cases where an index or count of 2^32 or more is malformed:
call,br, astruct.getfield and anarray.new_fixedcount. Acallindex of 2^32-1 parses and fails validation. wabt accepts thecallandbrcases.