From 1381e63d6caac1d5d064b60f6e2cb11bf0608e14 Mon Sep 17 00:00:00 2001 From: kevlo Date: Wed, 22 Feb 2012 06:27:20 +0000 Subject: Handle NULL return from crypt(3). Mostly from DragonFly --- usr.bin/enigma/enigma.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'usr.bin/enigma/enigma.c') 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; -- cgit v1.1