From 38bf64b415376f1419cd798fd753736960355bf5 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Fri, 22 Nov 2013 10:03:07 +0100 Subject: first version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/passphrase.c | 16 +++------------- src/passphrase.h | 8 ++++---- 2 files changed, 7 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/passphrase.c b/src/passphrase.c index 93cfd9f..a3ca289 100644 --- a/src/passphrase.c +++ b/src/passphrase.c @@ -21,8 +21,6 @@ #include #include -#include "config.h" - #include "passphrase.h" @@ -38,7 +36,7 @@ static struct termios saved_stty; /** * Reads the passphrase from stdin * - * @return The passphrase, should be `free`:ed + * @return The passphrase, should be wiped `free`:ed, `NULL` on error */ char* get_passphrase(void) { @@ -52,11 +50,7 @@ char* get_passphrase(void) int c; if (rc == NULL) - { - perror("malloc"); - sleep(ERROR_SLEEP); - _exit(1); - } + return NULL; /* Read password until EOF or Enter, skip all \0 as that is probably not a part of the passphrase (good luck typing @@ -71,11 +65,7 @@ char* get_passphrase(void) *(rc + len++) = c; if (len == size) if ((rc = realloc(rc, (size <<= 1L) * sizeof(char))) == NULL) - { - perror("realloc"); - sleep(ERROR_SLEEP); - _exit(1); - } + return NULL; } } diff --git a/src/passphrase.h b/src/passphrase.h index 8dbc39d..9a1baa5 100644 --- a/src/passphrase.h +++ b/src/passphrase.h @@ -23,19 +23,19 @@ /** * Reads the passphrase from stdin * - * @return The passphrase, should be `free`:ed + * @return The passphrase, should be wiped `free`:ed, `NULL` on error */ -char* get_passphrase(void); +extern char* get_passphrase(void); /** * Disable echoing and do anything else to the terminal settnings `get_passphrase` requires */ -void disable_echo(void); +extern void disable_echo(void); /** * Undo the actions of `disable_echo` */ -void reenable_echo(void); +extern void reenable_echo(void); #endif -- cgit v1.2.3-70-g09d2