From a404abd969bdb1e32d81382a65c9d770f867862b Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Fri, 4 Dec 2015 22:46:14 +0100 Subject: m MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/passphrase.c | 7 +++++-- src/passphrase.h | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/passphrase.c b/src/passphrase.c index 3c91907..9e5a7e8 100644 --- a/src/passphrase.c +++ b/src/passphrase.c @@ -248,7 +248,7 @@ char* passphrase_read(void) /** * Used to make sure that `passphrase_wipe` is not optimised away even within this library */ -volatile sig_atomic_t passphrase_wipe_volatile = 1; +volatile sig_atomic_t passphrase_wipe_volatile________________ = 1; /** * Forcable write NUL characters to a passphrase @@ -256,10 +256,13 @@ volatile sig_atomic_t passphrase_wipe_volatile = 1; * @param ptr The password to wipe * @param n The number of characters to wipe */ +#ifdef __GNUC__ +__attribute__((optimize("-O0"))) +#endif void passphrase_wipe(volatile char* ptr, size_t n) { size_t i; - for (i = 0; (i < n) && passphrase_wipe_volatile; i++) + for (i = 0; (i < n) && passphrase_wipe_volatile________________; i++) *(ptr + i) = 0; } diff --git a/src/passphrase.h b/src/passphrase.h index e0537e8..85faffd 100644 --- a/src/passphrase.h +++ b/src/passphrase.h @@ -33,7 +33,7 @@ extern char* passphrase_read(void); * @param ptr The password to wipe * @param n The number of characters to wipe */ -extern void passphrase_wipe(volatile char* ptr, size_t n) __attribute__((optimize("-O0"))); +extern void passphrase_wipe(volatile char*, size_t); /** * Disable echoing and do anything else to the terminal settnings `passphrase_read` requires -- cgit v1.2.3-70-g09d2