Skip to content

Bech32 fix - #548

Merged
jgriffiths merged 3 commits into
masterfrom
bech32_fix
Sep 3, 2026
Merged

jgriffiths merged 3 commits into
masterfrom
bech32_fix

Conversation

@jgriffiths

Copy link
Copy Markdown
Contributor

#545 plus a build fix

brunoerg and others added 3 commits September 3, 2026 15:07
bech32_encode() allows an encoded address of up to 90 characters, as
BIP-173 specifies, but wally_addr_segwit_from_bytes() encodes into a
90 byte stack buffer. When the address is exactly 90 characters long the
NUL terminator is written one byte past the end of the buffer.

Any 30 character hrp with a 32 byte version 0 program hits the boundary,
as does any other combination whose encoded length is 90.

Size the buffer for the maximum length plus the terminator, matching
what the blech32 encoder already does, and add the boundary case to the
bech32 test vectors so it is exercised in both directions.

Found by bitcoinfuzz.
@jgriffiths
jgriffiths merged commit 374df23 into master Sep 3, 2026
4 checks passed
@jgriffiths
jgriffiths deleted the bech32_fix branch September 3, 2026 04:09
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