aboutsummaryrefslogtreecommitdiffstats
path: root/src/passphrase.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2013-11-22 10:03:07 +0100
committerMattias Andrée <maandree@operamail.com>2013-11-22 10:03:07 +0100
commit38bf64b415376f1419cd798fd753736960355bf5 (patch)
treec9b725f2bf140641fc9faf7bbe7d5786183158e1 /src/passphrase.c
parentupdate copying notice (diff)
downloadlibpassphrase-38bf64b415376f1419cd798fd753736960355bf5.tar.gz
libpassphrase-38bf64b415376f1419cd798fd753736960355bf5.tar.bz2
libpassphrase-38bf64b415376f1419cd798fd753736960355bf5.tar.xz
first version
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/passphrase.c')
-rw-r--r--src/passphrase.c16
1 files changed, 3 insertions, 13 deletions
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 <termios.h>
#include <unistd.h>
-#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;
}
}