This commit is contained in:
Wendigo 2024-11-24 10:47:58 +01:00 committed by GitHub
commit 7331a68d35
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -373,7 +373,17 @@ typedef unsigned char BOOLEAN;
#if defined(_WIN32) && !defined(_UEFI)
#define burn(mem,size) do { volatile char *burnm = (volatile char *)(mem); size_t burnc = size; RtlSecureZeroMemory (mem, size); while (burnc--) *burnm++ = 0; } while (0)
#else
#define burn(mem,size) do { volatile char *burnm = (volatile char *)(mem); int burnc = size; while (burnc--) *burnm++ = 0; } while (0)
#define burn(mem, size) do { \
volatile char *burnm = (volatile char *)(mem); \
size_t burnc = (size_t)(size); \
if (burnm && burnc > 0) { \
for (size_t i = 0; i < burnc; i++) { \
if (&burnm[i] >= mem && &burnm[i] < mem + size) { \
burnm[i] = 0; \
} \
} \
} \
} while (0)
#endif
#define volatile_memcpy(d,s,size) do { volatile char *destm = (volatile char *)(d); volatile char *srcm = (volatile char *)(s); size_t memc = size; while (memc--) *destm++ = *srcm++; } while (0)