mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-09-11 21:20:39 +02:00
bech32: bound overlength error locations
`LocateErrors()` returns multiple useful positions for character and checksum errors, but an overlength string has one structural error. Every character from the limit onward is outside the permitted address, so listing each position adds no diagnostic value. `validateaddress` converts every returned position into a `UniValue` number before serializing the response. An authenticated request below the HTTP body limit can therefore require several gigabytes of memory. Return only the first position beyond the length limit, which identifies where the violation begins. Character and checksum errors continue to report multiple useful positions when they can be determined, and the existing unit and functional tests cover both behaviors.
This commit is contained in:
@@ -68,7 +68,7 @@ class InvalidAddressErrorMessageTest(BitcoinTestFramework):
|
||||
self.check_invalid(BECH32_INVALID_BECH32M, 'Version 0 witness address must use Bech32 checksum')
|
||||
self.check_invalid(BECH32_INVALID_VERSION, 'Invalid Bech32 address witness version')
|
||||
self.check_invalid(BECH32_INVALID_V0_SIZE, "Invalid Bech32 v0 address program size (21 bytes), per BIP141")
|
||||
self.check_invalid(BECH32_TOO_LONG, 'Bech32 string too long', list(range(90, 108)))
|
||||
self.check_invalid(BECH32_TOO_LONG, 'Bech32 string too long', [90])
|
||||
self.check_invalid(BECH32_ONE_ERROR, 'Invalid Bech32 checksum', [9])
|
||||
self.check_invalid(BECH32_TWO_ERRORS, 'Invalid Bech32 checksum', [22, 43])
|
||||
self.check_invalid(BECH32_ONE_ERROR_CAPITALS, 'Invalid Bech32 checksum', [38])
|
||||
|
||||
Reference in New Issue
Block a user