diff options
author | Mattias Andrée <maandree@operamail.com> | 2015-12-04 22:46:14 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2015-12-04 22:46:14 +0100 |
commit | a404abd969bdb1e32d81382a65c9d770f867862b (patch) | |
tree | 1cd885be2a9908ece8cca12f743b73c9b551e042 | |
parent | whitespace + only use gcc pragmas if using gcc (diff) | |
download | libpassphrase-a404abd969bdb1e32d81382a65c9d770f867862b.tar.gz libpassphrase-a404abd969bdb1e32d81382a65c9d770f867862b.tar.bz2 libpassphrase-a404abd969bdb1e32d81382a65c9d770f867862b.tar.xz |
m
Signed-off-by: Mattias Andrée <maandree@operamail.com>
-rw-r--r-- | src/passphrase.c | 7 | ||||
-rw-r--r-- | src/passphrase.h | 2 |
2 files changed, 6 insertions, 3 deletions
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 |