Merge branch '0.4.x' into 0.5.x

Conflicts:
	src/bitcoinrpc.cpp
This commit is contained in:
Luke Dashjr
2012-11-14 21:25:29 +00:00
6 changed files with 15 additions and 10 deletions

View File

@@ -17,6 +17,8 @@
#include <string>
#include <vector>
#include <openssl/crypto.h> // for OPENSSL_cleanse()
#include "bignum.h"
static const char* pszBase58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
@@ -188,7 +190,7 @@ protected:
{
// zero the memory, as it may contain sensitive data
if (!vchData.empty())
memset(&vchData[0], 0, vchData.size());
OPENSSL_cleanse(&vchData[0], vchData.size());
}
void SetData(int nVersionIn, const void* pdata, size_t nSize)
@@ -219,7 +221,7 @@ public:
vchData.resize(vchTemp.size() - 1);
if (!vchData.empty())
memcpy(&vchData[0], &vchTemp[1], vchData.size());
memset(&vchTemp[0], 0, vchTemp.size());
OPENSSL_cleanse(&vchTemp[0], vchData.size());
return true;
}

View File

@@ -33,8 +33,8 @@ bool CCrypter::SetKeyFromPassphrase(const SecureString& strKeyData, const std::v
if (i != (int)WALLET_CRYPTO_KEY_SIZE)
{
memset(&chKey, 0, sizeof chKey);
memset(&chIV, 0, sizeof chIV);
OPENSSL_cleanse(chKey, sizeof(chKey));
OPENSSL_cleanse(chIV, sizeof(chIV));
return false;
}

View File

@@ -72,8 +72,8 @@ public:
void CleanKey()
{
memset(&chKey, 0, sizeof chKey);
memset(&chIV, 0, sizeof chIV);
OPENSSL_cleanse(chKey, sizeof(chKey));
OPENSSL_cleanse(chIV, sizeof(chIV));
munlock(&chKey, sizeof chKey);
munlock(&chIV, sizeof chIV);
fKeySet = false;

View File

@@ -3096,7 +3096,7 @@ public:
CBlock* CreateNewBlock(CReserveKey& reservekey)
{
CBlockIndex* pindexPrev = pindexBest;
CBlockIndex* pindexPrev;
// Create new block
auto_ptr<CBlock> pblock(new CBlock());
@@ -3118,6 +3118,7 @@ CBlock* CreateNewBlock(CReserveKey& reservekey)
CRITICAL_BLOCK(cs_main)
CRITICAL_BLOCK(cs_mapTransactions)
{
pindexPrev = pindexBest;
CTxDB txdb("r");
// Priority order to process transactions

View File

@@ -14,6 +14,8 @@
#include <cstring>
#include <cstdio>
#include <openssl/crypto.h> // for OPENSSL_cleanse()
#include <boost/type_traits/is_fundamental.hpp>
#include <boost/tuple/tuple.hpp>
#include <boost/tuple/tuple_comparison.hpp>
@@ -824,7 +826,7 @@ struct secure_allocator : public std::allocator<T>
{
if (p != NULL)
{
memset(p, 0, sizeof(T) * n);
OPENSSL_cleanse(p, sizeof(T) * n);
munlock(p, sizeof(T) * n);
}
std::allocator<T>::deallocate(p, n);
@@ -858,7 +860,7 @@ struct zero_after_free_allocator : public std::allocator<T>
void deallocate(T* p, std::size_t n)
{
if (p != NULL)
memset(p, 0, sizeof(T) * n);
OPENSSL_cleanse(p, sizeof(T) * n);
std::allocator<T>::deallocate(p, n);
}
};

View File

@@ -131,7 +131,7 @@ void RandAddSeedPerfmon()
if (ret == ERROR_SUCCESS)
{
RAND_add(pdata, nSize, nSize/100.0);
memset(pdata, 0, nSize);
OPENSSL_cleanse(pdata, nSize);
printf("%s RandAddSeed() %d bytes\n", DateTimeStrFormat("%x %H:%M", GetTime()).c_str(), nSize);
}
#endif