Advertisement
PVS-StudioWarnings

PVS-Studio warning V612 for Bitcoin

Nov 21st, 2014
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.23 KB | None | 0 0
  1. bool CCryptoKeyStore::Unlock(const CKeyingMaterial& vMasterKeyIn)
  2. {
  3.   {
  4.     LOCK(cs_KeyStore);
  5.     if (!SetCrypted())
  6.       return false;
  7.  
  8.     CryptedKeyMap::const_iterator mi = mapCryptedKeys.begin();
  9.     for (; mi != mapCryptedKeys.end(); ++mi)
  10.     {
  11.       const CPubKey &vchPubKey = (*mi).second.first;
  12.       const std::vector<unsigned char> &vchCryptedSecret =
  13.         (*mi).second.second;
  14.       CKeyingMaterial vchSecret;
  15.       if(!DecryptSecret(vMasterKeyIn, vchCryptedSecret,
  16.                         vchPubKey.GetHash(), vchSecret))
  17.           return false;
  18.       if (vchSecret.size() != 32)
  19.           return false;
  20.       CKey key;
  21.       key.Set(vchSecret.begin(), vchSecret.end(),
  22.               vchPubKey.IsCompressed());
  23.       if (key.GetPubKey() == vchPubKey)
  24.           break;
  25.       return false;
  26.     }
  27.     vMasterKey = vMasterKeyIn;
  28.   }
  29.   NotifyStatusChanged(this);
  30.   return true;
  31. }
  32.  
  33. This suspicious code was found in Bitcoin project by PVS-Studio static code analyzer.
  34. Warning message is:
  35. V612 An unconditional 'return' within a loop. crypter.cpp 169
  36.  
  37. PVS-Studio is a static analyzer for detecting bugs in the source code of applications written in C, C++, C++11, C++/CX. Site: http://www.viva64.com/en/pvs-studio/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement