From 3cd1f90972bd3ec39bdcde537e591ae4334eddb3 Mon Sep 17 00:00:00 2001 From: Conrad Meyer Date: Wed, 4 Oct 2017 01:12:26 +0000 Subject: [PATCH] chpass(1): Check crypt(3) return and handle error appropriately This change is spiritually similar to the earlier r231994. PR: 222756 Submitted by: Lubos Boucek Obtained from: DragonflyBSD 2020c8fec4168a5020f984a093224fade3074b25 --- usr.bin/chpass/chpass.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/usr.bin/chpass/chpass.c b/usr.bin/chpass/chpass.c index 9f9be5335a68..74c96beb92e7 100644 --- a/usr.bin/chpass/chpass.c +++ b/usr.bin/chpass/chpass.c @@ -82,7 +82,7 @@ main(int argc, char *argv[]) struct passwd lpw, *old_pw, *pw; int ch, pfd, tfd; const char *password; - char *arg = NULL; + char *arg = NULL, *cryptpw; uid_t uid; #ifdef YP struct ypclnt *ypclnt; @@ -228,8 +228,8 @@ main(int argc, char *argv[]) if (old_pw && !master_mode) { password = getpass("Password: "); - if (strcmp(crypt(password, old_pw->pw_passwd), - old_pw->pw_passwd) != 0) + cryptpw = crypt(password, old_pw->pw_passwd); + if (cryptpw == NULL || strcmp(cryptpw, old_pw->pw_passwd) != 0) baduser(); } else { password = "";