0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-02 09:46:52 -05:00

Merge bitcoin/bitcoin#26950: cleanse: switch to SecureZeroMemory for Windows cross-compile

c399c80a09 cleanse: Use SecureZeroMemory for mingw-w64 (release) builds (fanquake)

Pull request description:

  This PR switches our Windows release builds to use the [`SecureZeroMemory()`](https://learn.microsoft.com/en-us/previous-versions/windows/desktop/legacy/aa366877(v=vs.85)) provided by mingw-w64.

ACKs for top commit:
  sipa:
    utACK c399c80a09
  TheCharlatan:
    ACK c399c80a09

Tree-SHA512: dbb20b16c85061d2f9408a3cf69cecc16765f8f61b25a1707146767b664c7ad0caf36975380814ef8e7c49a30199daebac6d5d7a3585354d1adac8e9770199c6
This commit is contained in:
merge-script 2024-07-26 07:08:49 +01:00
commit 02c76ad652
No known key found for this signature in database
GPG key ID: 2EEB9F5CC09526C1

View file

@ -7,14 +7,14 @@
#include <cstring>
#if defined(_MSC_VER)
#include <Windows.h> // For SecureZeroMemory.
#if defined(WIN32)
#include <windows.h>
#endif
void memory_cleanse(void *ptr, size_t len)
{
#if defined(_MSC_VER)
/* SecureZeroMemory is guaranteed not to be optimized out by MSVC. */
#if defined(WIN32)
/* SecureZeroMemory is guaranteed not to be optimized out. */
SecureZeroMemory(ptr, len);
#else
std::memset(ptr, 0, len);