mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
common: 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' and
remove duplicated checks.
--
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 <jussi.kivilinna@iki.fi>
(cherry picked from commit 2a650772b4
)
This commit is contained in:
parent
edeebe0a6b
commit
21fdef6963
3 changed files with 30 additions and 21 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue