[PATCH 2/2] _gcry_burn_stack: use memset for clearing memory

Jussi Kivilinna jussi.kivilinna at iki.fi
Sun Mar 11 16:10:54 CET 2018


* src/misc.c (__gcry_burn_stack) [HAVE_VLA]: Use 'memset' for clearing
stack.
--

Patch switches stacking burning to use faster memset instead of
wipememory. Memset is accessed through volatile function pointer,
so that compiler will not optimize away the call.

Signed-off-by: Jussi Kivilinna <jussi.kivilinna at iki.fi>
---
 0 files changed

diff --git a/src/misc.c b/src/misc.c
index 002a84f69..47d2dc712 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -501,11 +501,12 @@ void
 __gcry_burn_stack (unsigned int bytes)
 {
 #ifdef HAVE_VLA
+    static void *(*volatile memset_ptr)(void *, int, size_t) = (void *)memset;
     /* (bytes == 0 ? 1 : bytes) == (!bytes + bytes) */
     unsigned int buflen = ((!bytes + bytes) + 63) & ~63;
-    volatile char buf[buflen];
+    char buf[buflen];
 
-    wipememory (buf, sizeof buf);
+    memset_ptr (buf, 0, sizeof buf);
 #else
     volatile char buf[64];
 




More information about the Gcrypt-devel mailing list