diff options
author | Jussi Kivilinna <[email protected]> | 2018-12-01 11:43:09 +0000 |
---|---|---|
committer | Jussi Kivilinna <[email protected]> | 2018-12-01 11:43:09 +0000 |
commit | 2a650772b4e1c78a4fd20bc88433930e5551fe9c (patch) | |
tree | 1ec63e3e9e09cba7dcaf080517379625769b98e0 /common/mischelp.h | |
parent | scd: Add strerror to new error message. (diff) | |
download | gnupg-2a650772b4e1c78a4fd20bc88433930e5551fe9c.tar.gz gnupg-2a650772b4e1c78a4fd20bc88433930e5551fe9c.zip |
common/mischelp: use platform memory zeroing function for wipememory
* common/mischelp.h (wipememory): Replace macro with function
prototype.
(wipememory2): Remove.
* common/mischelp.c (wipememory): New.
* configure.ac (AC_CHECK_FUNCS): Check for 'explicit_bzero'.
--
In new wipememory function, memory is cleared through platform
provided secure memory zeroing function, SecureZeroMemory
or explicit_bzero.
If none of these is available, memset is called through
volatile function pointer to so that compiler won't optimize
away the call.
Signed-off-by: Jussi Kivilinna <[email protected]>
Diffstat (limited to 'common/mischelp.h')
-rw-r--r-- | common/mischelp.h | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/common/mischelp.h b/common/mischelp.h index 18ec96edf..bdee5a443 100644 --- a/common/mischelp.h +++ b/common/mischelp.h @@ -47,15 +47,9 @@ time_t timegm (struct tm *tm); #define DIM(v) (sizeof(v)/sizeof((v)[0])) #define DIMof(type,member) DIM(((type *)0)->member) -/* To avoid that a compiler optimizes certain memset calls away, these - macros may be used instead. */ -#define wipememory2(_ptr,_set,_len) do { \ - volatile char *_vptr=(volatile char *)(_ptr); \ - size_t _vlen=(_len); \ - while(_vlen) { *_vptr=(_set); _vptr++; _vlen--; } \ - } while(0) -#define wipememory(_ptr,_len) wipememory2(_ptr,0,_len) - +/* To avoid that a compiler optimizes certain memset calls away, + wipememory function may be used instead. */ +void wipememory(void *ptr, size_t len); /* Include hacks which are mainly required for Slowaris. */ #ifdef GNUPG_COMMON_NEED_AFLOCAL |