Browse Source

use corrected version of zeromem() from @dtrebbien

Steffen Jaeckel 13 years ago
parent
commit
7050bdb7c8
2 changed files with 4 additions and 4 deletions
  1. 1 1
      src/headers/tomcrypt_misc.h
  2. 3 3
      src/misc/zeromem.c

+ 1 - 1
src/headers/tomcrypt_misc.h

@@ -8,7 +8,7 @@ int base64_decode(const unsigned char *in,  unsigned long len,
 #endif
 #endif
 
 
 /* ---- MEM routines ---- */
 /* ---- MEM routines ---- */
-void zeromem(void *dst, size_t len);
+void zeromem(volatile void *dst, size_t len);
 void burn_stack(unsigned long len);
 void burn_stack(unsigned long len);
 
 
 const char *error_to_string(int err);
 const char *error_to_string(int err);

+ 3 - 3
src/misc/zeromem.c

@@ -20,12 +20,12 @@
    @param out    The destination of the area to zero
    @param out    The destination of the area to zero
    @param outlen The length of the area to zero (octets)
    @param outlen The length of the area to zero (octets)
 */
 */
-void zeromem(void *out, size_t outlen)
+void zeromem(volatile void *out, size_t outlen)
 {
 {
-   unsigned char *mem = out;
+   volatile char *mem = out;
    LTC_ARGCHKVD(out != NULL);
    LTC_ARGCHKVD(out != NULL);
    while (outlen-- > 0) {
    while (outlen-- > 0) {
-      *mem++ = 0;
+      *mem++ = '\0';
    }
    }
 }
 }