mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 14:38:29 +01:00
util: Don't allow base58-decoding of std::string:s containing non-base58 characters
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include <hash.h>
|
||||
#include <uint256.h>
|
||||
#include <util/strencodings.h>
|
||||
#include <util/string.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
@@ -130,6 +131,9 @@ std::string EncodeBase58(const std::vector<unsigned char>& vch)
|
||||
|
||||
bool DecodeBase58(const std::string& str, std::vector<unsigned char>& vchRet, int max_ret_len)
|
||||
{
|
||||
if (!ValidAsCString(str)) {
|
||||
return false;
|
||||
}
|
||||
return DecodeBase58(str.c_str(), vchRet, max_ret_len);
|
||||
}
|
||||
|
||||
@@ -161,5 +165,8 @@ bool DecodeBase58Check(const char* psz, std::vector<unsigned char>& vchRet, int
|
||||
|
||||
bool DecodeBase58Check(const std::string& str, std::vector<unsigned char>& vchRet, int max_ret)
|
||||
{
|
||||
if (!ValidAsCString(str)) {
|
||||
return false;
|
||||
}
|
||||
return DecodeBase58Check(str.c_str(), vchRet, max_ret);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user