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/tools/tor-gencert.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/tools') diff --git a/src/tools/tor-gencert.c b/src/tools/tor-gencert.c index 38b2101a3..c7ab8dc61 100644 --- a/src/tools/tor-gencert.c +++ b/src/tools/tor-gencert.c @@ -105,7 +105,7 @@ load_passphrase(void) cp = memchr(buf, '\n', n); passphrase_len = cp-buf; passphrase = tor_strndup(buf, passphrase_len); - memset(buf, 0, sizeof(buf)); + memwipe(buf, 0, sizeof(buf)); return 0; } @@ -113,7 +113,7 @@ static void clear_passphrase(void) { if (passphrase) { - memset(passphrase, 0, passphrase_len); + memwipe(passphrase, 0, passphrase_len); tor_free(passphrase); } } @@ -191,7 +191,7 @@ parse_commandline(int argc, char **argv) } } - memset(&s, 0, sizeof(s)); + memwipe(&s, 0, sizeof(s)); if (verbose) set_log_severity_config(LOG_DEBUG, LOG_ERR, &s); else -- cgit v1.2.3