diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2014-06-16 17:29:35 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2014-06-16 17:29:43 +0200 |
commit | f73082db87b9e07ddcd4656f4fc309c4d2854285 (patch) | |
tree | 8c02cc98a714247c7590b136e20b17505a1eb656 | |
parent | 0075337020d4cf8614c40b2c98c0bbef124bbc56 (diff) | |
parent | 88df548dde280efac8eb33520f8192885455bc03 (diff) |
Merge pull request #4337
88df548 base58: add paranoid return value checks (Jeff Garzik)
-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 5975703887..1bd64684e5 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; |