summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pw
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.sbin/pw
parent749a5f142f69ff02971e21c6dca8eab3f65d8de9 (diff)
downloadFreeBSD-src-1381e63d6caac1d5d064b60f6e2cb11bf0608e14.zip
FreeBSD-src-1381e63d6caac1d5d064b60f6e2cb11bf0608e14.tar.gz
Handle NULL return from crypt(3). Mostly from DragonFly
Diffstat (limited to 'usr.sbin/pw')
-rw-r--r--usr.sbin/pw/pw_user.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/usr.sbin/pw/pw_user.c b/usr.sbin/pw/pw_user.c
index 0001a41..b59789c 100644
--- a/usr.sbin/pw/pw_user.c
+++ b/usr.sbin/pw/pw_user.c
@@ -1028,6 +1028,7 @@ pw_pwcrypt(char *password)
{
int i;
char salt[SALTSIZE + 1];
+ char *cryptpw;
static char buf[256];
@@ -1038,7 +1039,10 @@ pw_pwcrypt(char *password)
salt[i] = chars[arc4random_uniform(sizeof(chars) - 1)];
salt[SALTSIZE] = '\0';
- return strcpy(buf, crypt(password, salt));
+ cryptpw = crypt(password, salt);
+ if (cryptpw == NULL)
+ errx(EX_CONFIG, "crypt(3) failure");
+ return strcpy(buf, cryptpw);
}
OpenPOWER on IntegriCloud