mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 15:09:59 +01:00
Add bounds checks in key_io before DecodeBase58Check
This commit is contained in:
@@ -54,15 +54,15 @@ BOOST_AUTO_TEST_CASE(base58_DecodeBase58)
|
||||
}
|
||||
std::vector<unsigned char> expected = ParseHex(test[0].get_str());
|
||||
std::string base58string = test[1].get_str();
|
||||
BOOST_CHECK_MESSAGE(DecodeBase58(base58string, result), strTest);
|
||||
BOOST_CHECK_MESSAGE(DecodeBase58(base58string, result, 256), strTest);
|
||||
BOOST_CHECK_MESSAGE(result.size() == expected.size() && std::equal(result.begin(), result.end(), expected.begin()), strTest);
|
||||
}
|
||||
|
||||
BOOST_CHECK(!DecodeBase58("invalid", result));
|
||||
BOOST_CHECK(!DecodeBase58("invalid", result, 100));
|
||||
|
||||
// check that DecodeBase58 skips whitespace, but still fails with unexpected non-whitespace at the end.
|
||||
BOOST_CHECK(!DecodeBase58(" \t\n\v\f\r skip \r\f\v\n\t a", result));
|
||||
BOOST_CHECK( DecodeBase58(" \t\n\v\f\r skip \r\f\v\n\t ", result));
|
||||
BOOST_CHECK(!DecodeBase58(" \t\n\v\f\r skip \r\f\v\n\t a", result, 3));
|
||||
BOOST_CHECK( DecodeBase58(" \t\n\v\f\r skip \r\f\v\n\t ", result, 3));
|
||||
std::vector<unsigned char> expected = ParseHex("971a55");
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(result.begin(), result.end(), expected.begin(), expected.end());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user