diff options
| author | Jeff Garzik <[email protected]> | 2014-06-11 23:20:37 -0400 |
|---|---|---|
| committer | Ross Nicoll <[email protected]> | 2014-08-28 23:13:27 +0100 |
| commit | cea6141e3212174bc26abf72b6be8c49fdeb77f0 (patch) | |
| tree | b01e6d8f4b4078e90c5db8a186c370156d9be817 /src/base58.cpp | |
| parent | Merge pull request #664 from rnicoll/1.8.1-dev-protocol (diff) | |
| download | discoin-cea6141e3212174bc26abf72b6be8c49fdeb77f0.tar.xz discoin-cea6141e3212174bc26abf72b6be8c49fdeb77f0.zip | |
base58: add paranoid return value checks
Rebased-From: 88df548
Diffstat (limited to 'src/base58.cpp')
| -rw-r--r-- | src/base58.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/base58.cpp b/src/base58.cpp index 597570388..1bd64684e 100644 --- a/src/base58.cpp +++ b/src/base58.cpp @@ -114,9 +114,8 @@ std::string EncodeBase58Check(const std::vector<unsigned char>& vchIn) { } bool DecodeBase58Check(const char* psz, std::vector<unsigned char>& vchRet) { - if (!DecodeBase58(psz, vchRet)) - return false; - if (vchRet.size() < 4) + if (!DecodeBase58(psz, vchRet) || + (vchRet.size() < 4)) { vchRet.clear(); return false; @@ -154,8 +153,8 @@ void CBase58Data::SetData(const std::vector<unsigned char> &vchVersionIn, const bool CBase58Data::SetString(const char* psz, unsigned int nVersionBytes) { std::vector<unsigned char> vchTemp; - DecodeBase58Check(psz, vchTemp); - if (vchTemp.size() < nVersionBytes) { + bool rc58 = DecodeBase58Check(psz, vchTemp); + if ((!rc58) || (vchTemp.size() < nVersionBytes)) { vchData.clear(); vchVersion.clear(); return false; |