aboutsummaryrefslogtreecommitdiff
path: root/src/base58.cpp
diff options
context:
space:
mode:
authorpracticalswift <practicalswift@users.noreply.github.com>2019-12-11 11:00:52 +0000
committerpracticalswift <practicalswift@users.noreply.github.com>2019-12-12 11:01:56 +0000
commitd945c6f5e6f61b6e289ac7da6834c18f1b677b0f (patch)
tree59a127942a439fd1bdb344daf929a0acbdd0e0ee /src/base58.cpp
parentff7a9992263f5a19f73097c86068b6150d213c23 (diff)
util: Don't allow base58-decoding of std::string:s containing non-base58 characters
Diffstat (limited to 'src/base58.cpp')
-rw-r--r--src/base58.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/base58.cpp b/src/base58.cpp
index a0149fb641..17d3f86ba8 100644
--- a/src/base58.cpp
+++ b/src/base58.cpp
@@ -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);
}