Commit 3425fee6 by yorah

util: git__memzero() tweaks

On Linux: fix a warning message related to the volatile qualifier (cast)
On Windows: use SecureZeroMemory()

On both, inline the call, so that no entry point can lead back to this "secure" memory zeroing.
parent 824cf80f
......@@ -722,12 +722,3 @@ void git__insertsort_r(
if (freeswap)
git__free(swapel);
}
void git__memzero(volatile void *data, size_t size)
{
volatile uint8_t *scan = data;
uint8_t *end = scan + size;
while (scan < end)
*scan++ = 0x0;
}
......@@ -325,6 +325,16 @@ extern size_t git__unescape(char *str);
* Safely zero-out memory, making sure that the compiler
* doesn't optimize away the operation.
*/
extern void git__memzero(volatile void *data, size_t size);
GIT_INLINE(void) git__memzero(void *data, size_t size)
{
#ifdef _MSC_VER
SecureZeroMemory((PVOID)data, size);
#else
volatile uint8_t *scan = (volatile uint8_t *)data;
while (size--)
*scan++ = 0x0;
#endif
}
#endif /* INCLUDE_util_h__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment