-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add fix and test for bech32 bad input
Thanks to Christian Reitter and Dr. Jochen Hoenicke for finding the issue.
- Loading branch information
1 parent
34bac73
commit c79eb6f
Showing
7 changed files
with
56 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include "config.h" | ||
|
||
#include <wally_core.h> | ||
#include <wally_address.h> | ||
#include <stdio.h> | ||
#include <stdbool.h> | ||
|
||
static const char *invalid = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefg"; | ||
|
||
static bool check_segwit_to_bytes() | ||
{ | ||
unsigned char *mem = calloc(90, sizeof(unsigned char)); | ||
size_t written; | ||
int ret; | ||
|
||
if (!mem) | ||
return false; | ||
|
||
ret = wally_addr_segwit_to_bytes(invalid, "tb", 0, mem, 90, &written); | ||
|
||
if (ret != WALLY_EINVAL) | ||
return false; | ||
|
||
return true; | ||
} | ||
|
||
int main(void) | ||
{ | ||
bool tests_ok = true; | ||
|
||
if (!check_segwit_to_bytes()) { | ||
printf("check_segwit_to_bytes test failed!\n"); | ||
tests_ok = false; | ||
} | ||
|
||
return tests_ok ? 0 : 1; | ||
} |
This file contains 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
This file contains 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