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/chkey/chkey.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'usr.bin/chkey') 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 -- cgit v1.1