Repository navigation
Conversation
When an account length would equal Multisig::LEN, the program appends a bare Uninitialized type with no length field. The Rust reader stops there, but getExtensionTypes always read a length, so it read past the end of the buffer and threw ERR_OUT_OF_RANGE on valid mints. Stop on Uninitialized and guard the loop so both the type and length fit before reading them. getAccountLenForMint goes through this function and is fixed with it.
Author
|
Status check on this one. It still applies to current One thing that may explain the silence: the workflow run for this branch is sitting at |
Contributor
Author
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.
Some valid Token-2022 mints make
getExtensionTypesthrowRangeError ERR_OUT_OF_RANGE.getAccountLenForMintthrows too, since it calls through to it.Two mints on mainnet are built this way today:
Why it happens: when an account's length would land exactly on
Multisig::LEN, the program appends two zero bytes, anUninitializedtype with no length field. The Rust reader stops there (try_for_each_tlv_extension_type). The JS reader always reads a length after the type, so on those mints it reads past the end of the buffer.What it costs: a wallet or tool that opens one of those mints and asks for its extensions crashes instead of showing the token.
unpackMintitself works, the follow up call is what fails.The change stops the loop when it sees
Uninitialized, and only reads a type and length when both fit in the buffer. That is the same order the program's reader uses.Testing:
test/unit/extensionTypes.test.tsuses the real 191 byte layout: MetadataPointer, then TokenMetadata, then the00 00padding. It fails onmainand passes with this change.npm run test:unit: 111 passingoxlint --max-warnings 0: cleanoxfmt --check: cleanCloses #1587