summaryrefslogtreecommitdiffstats
path: root/usr.bin/enigma/enigma.c
diff options
context:
space:
mode:
authorkevlo <kevlo@FreeBSD.org>2012-02-22 06:27:20 +0000
committerkevlo <kevlo@FreeBSD.org>2012-02-22 06:27:20 +0000
commit1381e63d6caac1d5d064b60f6e2cb11bf0608e14 (patch)
tree456afe25d5d911e27dc003830e6ca01ed80dab54 /usr.bin/enigma/enigma.c
parent749a5f142f69ff02971e21c6dca8eab3f65d8de9 (diff)
downloadFreeBSD-src-1381e63d6caac1d5d064b60f6e2cb11bf0608e14.zip
FreeBSD-src-1381e63d6caac1d5d064b60f6e2cb11bf0608e14.tar.gz
Handle NULL return from crypt(3). Mostly from DragonFly
Diffstat (limited to 'usr.bin/enigma/enigma.c')
-rw-r--r--usr.bin/enigma/enigma.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/usr.bin/enigma/enigma.c b/usr.bin/enigma/enigma.c
index 49cb006..893766e 100644
--- a/usr.bin/enigma/enigma.c
+++ b/usr.bin/enigma/enigma.c
@@ -41,9 +41,15 @@ setup(char *pw)
char salt[3];
unsigned rnd;
int32_t seed;
+ char *cryptpw;
strlcpy(salt, pw, sizeof(salt));
- memcpy(buf, crypt(pw, salt), sizeof(buf));
+ cryptpw = crypt(pw, salt);
+ if (cryptpw == NULL) {
+ fprintf(stderr, "crypt(3) failure\n");
+ exit(1);
+ }
+ memcpy(buf, cryptpw, sizeof(buf));
seed = 123;
for (i=0; i<13; i++)
seed = seed*buf[i] + i;
OpenPOWER on IntegriCloud