summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Lo <kevlo@FreeBSD.org>2012-02-22 06:27:20 +0000
committerKevin Lo <kevlo@FreeBSD.org>2012-02-22 06:27:20 +0000
commite556d6cfc8f43ab6477ba735e9dc9a11a65c52d6 (patch)
tree2471e86efe94f0fdfd3935bb0c5693a5339b3187
parent2522cfffa2dbf5725baa06c63a3c76e608472104 (diff)
downloadpw-darwin-e556d6cfc8f43ab6477ba735e9dc9a11a65c52d6.tar.gz
pw-darwin-e556d6cfc8f43ab6477ba735e9dc9a11a65c52d6.tar.zst
pw-darwin-e556d6cfc8f43ab6477ba735e9dc9a11a65c52d6.zip
Handle NULL return from crypt(3). Mostly from DragonFly
-rw-r--r--pw/pw_user.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/pw/pw_user.c b/pw/pw_user.c
index 0001a41..b59789c 100644
--- a/pw/pw_user.c
+++ b/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);
}