Skip to content

That time Pieter Wuille tested us all and we failed him #2061

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

rustyrussell
Copy link
Contributor

@rustyrussell rustyrussell commented Oct 31, 2018

Fixes #2063 as a side-effect.

Copied from upstream:

 sipa/bech32@2b0aac6

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
… onchain addr."

This reverts commit 6af8f29.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>

hrp = tal_arr(tmpctx, char, strlen(str));
data = tal_arr(tmpctx, u5, strlen(str));
hrp = tal_arr(tmpctx, char, strlen(str) - 6);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i realize this is a revert, so maybe this is already taken care of, but if not can you add some context about why these offsets are necessary, maybe as a code comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's actually documented in the bech32 reference code header to have these requirements.

The reason: bech32 includes a 30-bit (6char) checksum, and a 1 between hrp and data, meaning hrp must be 7 chars shorter. Plus one for NUL terminator, so -6.

The data is not NUL-terminated, and the code insists that hrp be at least one letter long, so that's -8.

But you made me re-read the code and write some test cases to be sure!

@cdecker
Copy link
Member

cdecker commented Nov 1, 2018

ACK 7e73ea7

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
@rustyrussell rustyrussell merged commit 0c545d0 into ElementsProject:master Nov 2, 2018
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.

3 participants