fix(address): getAddress() returns a malformed 41-nibble address for over-length ICAP input#5154
Open
sravan27 wants to merge 1 commit into
Open
fix(address): getAddress() returns a malformed 41-nibble address for over-length ICAP input#5154sravan27 wants to merge 1 commit into
sravan27 wants to merge 1 commit into
Conversation
getAddress() left-padded the base36 ICAP body to >=40 nibbles but never capped at 40, so an over-length body returned a malformed 41-nibble string that isAddress() rejects and getAddress() itself throws on.
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.
Bug
getAddress()returns a malformed 41-nibble string for an over-length ICAP address — a value it itself rejects.getAddressis documented to return a normalized, checksummed 20-byte address or throw. Here it returns a 41-nibble value that failsisAddress()and thatgetAddress()rejects on the next call — a contract violation an app would propagate downstream (display, comparison, RPC).Cause
src.ts/address/address.ts, ICAP branch:The regex
/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/permits a 31-char base36 body, and36**31 > 2**160, soresultcan be 41 nibbles. The normalization only enforces a 40-nibble minimum, never a maximum.Fix
Assert the decoded result is exactly 40 nibbles (i.e. value
< 2**160); reject otherwise:Verified:
"Z".repeat(31)body (value ≥ 2^160) now throwsinvalid address; valid ≤30-char bodies and in-range 31-char bodies are unaffected (still pad to exactly 40 and checksum normally).