diff options
author | yorah <yoram.harmelin@gmail.com> | 2013-06-17 14:27:34 +0200 |
---|---|---|
committer | yorah <yoram.harmelin@gmail.com> | 2013-06-17 15:42:33 +0200 |
commit | 3425fee63773813a48f596637609efaa36428713 (patch) | |
tree | 0fa2e07c65d93b1e300d51631e2932f8f4973ed7 /src/util.h | |
parent | 824cf80f061ab31f45c94576f9e75533201a4578 (diff) | |
download | libgit2-3425fee63773813a48f596637609efaa36428713.tar.gz |
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.
Diffstat (limited to 'src/util.h')
-rw-r--r-- | src/util.h | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/util.h b/src/util.h index 0de466677..1ef9e65b5 100644 --- a/src/util.h +++ b/src/util.h @@ -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__ */ |