From 49dd5ef3a3d1775fdc3c0a7d069d3097b3baeeec Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Wed, 7 Nov 2012 16:09:58 -0500 Subject: Add and use and unlikely-to-be-eliminated memwipe() Apparently some compilers like to eliminate memset() operations on data that's about to go out-of-scope. I've gone with the safest possible replacement, which might be a bit slow. I don't think this is critical path in any way that will affect performance, but if it is, we can work on that in 0.2.4. Fixes bug 7352. --- src/common/aes.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/common/aes.c') diff --git a/src/common/aes.c b/src/common/aes.c index 59d864a3d..295a90749 100644 --- a/src/common/aes.c +++ b/src/common/aes.c @@ -106,7 +106,7 @@ aes_cipher_free(aes_cnt_cipher_t *cipher) if (!cipher) return; EVP_CIPHER_CTX_cleanup(&cipher->evp); - memset(cipher, 0, sizeof(aes_cnt_cipher_t)); + memwipe(cipher, 0, sizeof(aes_cnt_cipher_t)); tor_free(cipher); } void @@ -373,7 +373,7 @@ aes_cipher_free(aes_cnt_cipher_t *cipher) if (cipher->using_evp) { EVP_CIPHER_CTX_cleanup(&cipher->key.evp); } - memset(cipher, 0, sizeof(aes_cnt_cipher_t)); + memwipe(cipher, 0, sizeof(aes_cnt_cipher_t)); tor_free(cipher); } -- cgit v1.2.3