diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-08-17 21:45:20 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-08-17 21:45:20 +0200 |
commit | fae64c97fb3a923eb2028539d035783548bc9fd7 (patch) | |
tree | 7c51962517916e7490994c38f178f5f0f4d82d5f /info | |
parent | add volatile to ptr in passphrase_wipe (diff) | |
download | libpassphrase-1408304770.tar.gz libpassphrase-1408304770.tar.bz2 libpassphrase-1408304770.tar.xz |
update manual1408304770
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'info')
-rw-r--r-- | info/libpassphrase.texinfo | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/info/libpassphrase.texinfo b/info/libpassphrase.texinfo index 7eaf9a5..bf1a2dd 100644 --- a/info/libpassphrase.texinfo +++ b/info/libpassphrase.texinfo @@ -133,6 +133,14 @@ saves all settings before changing them and @code{passphrase_reenable_echo} applies to saved settings. +@item void passphrase_wipe(char*, size_t) +When you are done using passhprase you should +erase it from the memory before freeing its +allocation. To do this securtly, call +@code{passphrase_wipe} with the passphase +as the first argument and the length of the +passphrase as the second argument. + @end table These three functions could be made into one @@ -150,12 +158,12 @@ been disabled. #include <passphrase.h> /* For libpassphrase */ #include <stdio.h> /* For output */ #include <stdlib.h> /* For free */ +#include <string.h> /* For strlen */ int main(int argc, char** argv) @{ /* Variables for the passphrase */ char* passphrase; - char* passphrase_; /* Hide the passphrase */ passphrase_disable_echo(); @@ -177,10 +185,8 @@ int main(int argc, char** argv) printf("You entered: %s\n", passphrase); /* Wipe and free the passphrase */ - passphrase_ = passphrase; - while (*passphrase) - *passphrase++ = 0; - free(passphrase_); + passphrase_wipe(passphrase, strlen(passphrase)); + free(passphrase); /* Stop hiding user input */ passphrase_reenable_echo(); |