diff options
author | kevlo <kevlo@FreeBSD.org> | 2012-02-22 06:27:20 +0000 |
---|---|---|
committer | kevlo <kevlo@FreeBSD.org> | 2012-02-22 06:27:20 +0000 |
commit | 1381e63d6caac1d5d064b60f6e2cb11bf0608e14 (patch) | |
tree | 456afe25d5d911e27dc003830e6ca01ed80dab54 /usr.bin/chkey/chkey.c | |
parent | 749a5f142f69ff02971e21c6dca8eab3f65d8de9 (diff) | |
download | FreeBSD-src-1381e63d6caac1d5d064b60f6e2cb11bf0608e14.zip FreeBSD-src-1381e63d6caac1d5d064b60f6e2cb11bf0608e14.tar.gz |
Handle NULL return from crypt(3). Mostly from DragonFly
Diffstat (limited to 'usr.bin/chkey/chkey.c')
-rw-r--r-- | usr.bin/chkey/chkey.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/usr.bin/chkey/chkey.c b/usr.bin/chkey/chkey.c index 3098271..4751a28 100644 --- a/usr.bin/chkey/chkey.c +++ b/usr.bin/chkey/chkey.c @@ -94,6 +94,9 @@ main(int argc, char **argv) #ifdef YP char *master; #endif +#ifdef YPPASSWD + char *cryptpw; +#endif while ((ch = getopt(argc, argv, "f")) != -1) switch(ch) { @@ -149,7 +152,8 @@ main(int argc, char **argv) pass = getpass("Password:"); #ifdef YPPASSWD if (!force) { - if (strcmp(crypt(pass, pw->pw_passwd), pw->pw_passwd) != 0) + cryptpw = crypt(pass, pw->pw_passwd); + if (cryptpw == NULL || strcmp(cryptpw, pw->pw_passwd) != 0) errx(1, "invalid password"); } #else |