aboutsummaryrefslogtreecommitdiffstats
path: root/info/libpassphrase.texinfo
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-08-17 21:45:20 +0200
committerMattias Andrée <maandree@operamail.com>2014-08-17 21:45:20 +0200
commitfae64c97fb3a923eb2028539d035783548bc9fd7 (patch)
tree7c51962517916e7490994c38f178f5f0f4d82d5f /info/libpassphrase.texinfo
parentadd volatile to ptr in passphrase_wipe (diff)
downloadlibpassphrase-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 '')
-rw-r--r--info/libpassphrase.texinfo16
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();