X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Fallocators.h;h=bb72117b3378a7f94518a5916edbfeb9dffe39a2;hb=47d3ceb3da845e216fc9577cbf52f8b5600e5f93;hp=99afa10c255829a2769dcbf7233c5943549aac3c;hpb=84a4a7763f386934da90e2bd1e355b70023fa9ca;p=novacoin.git diff --git a/src/allocators.h b/src/allocators.h index 99afa10..bb72117 100644 --- a/src/allocators.h +++ b/src/allocators.h @@ -9,12 +9,13 @@ #include #include #include +#include // for OPENSSL_cleanse() #ifdef WIN32 #ifdef _WIN32_WINNT #undef _WIN32_WINNT #endif -#define _WIN32_WINNT 0x0501 +#define _WIN32_WINNT 0x0601 #define WIN32_LEAN_AND_MEAN 1 #ifndef NOMINMAX #define NOMINMAX @@ -143,7 +144,7 @@ public: bool Lock(const void *addr, size_t len) { #ifdef WIN32 - return VirtualLock(const_cast(addr), len); + return VirtualLock(const_cast(addr), len) != 0; #else return mlock(addr, len) == 0; #endif @@ -154,7 +155,7 @@ public: bool Unlock(const void *addr, size_t len) { #ifdef WIN32 - return VirtualUnlock(const_cast(addr), len); + return VirtualUnlock(const_cast(addr), len) != 0; #else return munlock(addr, len) == 0; #endif @@ -212,7 +213,7 @@ struct secure_allocator : public std::allocator { if (p != NULL) { - memset(p, 0, sizeof(T) * n); + OPENSSL_cleanse(p, sizeof(T) * n); LockedPageManager::instance.UnlockRange(p, sizeof(T) * n); } std::allocator::deallocate(p, n); @@ -246,7 +247,7 @@ struct zero_after_free_allocator : public std::allocator 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::deallocate(p, n); } };