Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Add fix and test for bech32 bad input
Thanks to Christian Reitter and Dr. Jochen Hoenicke for finding the issue.
- Loading branch information
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
@@ -39,6 +39,7 @@ src/stamp-h1 | ||
src/test/Makefile | ||
src/test/Makefile.in | ||
src/wallycore.pc | ||
src/test_bech32* | ||
src/test_clear* | ||
src/test_tx* | ||
src/test_elements_tx* | ||
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
@@ -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
@@ -23,6 +23,7 @@ rm -f src/*pyc | ||
rm -f src/test/*pyc | ||
rm -f src/config.h.in | ||
rm -rf src/lcov* | ||
rm -f src/test_bech32* | ||
rm -f src/test_clear* | ||
rm -f src/test_tx* | ||
rm -f src/test-suite.log | ||