summaryrefslogtreecommitdiffstats
path: root/chpass
diff options
context:
space:
mode:
authorConrad Meyer <cem@FreeBSD.org>2017-10-04 01:12:26 +0000
committerConrad Meyer <cem@FreeBSD.org>2017-10-04 01:12:26 +0000
commitdbace80f4239d777ec37376c0c42c6401d8bdf8f (patch)
treeda2d29cd715fa3ddc3e87bb0a7e336aa122450ff /chpass
parentc0bc488b2c50819975f1c59b5b26e3ce8c4f5da4 (diff)
downloadpw-darwin-dbace80f4239d777ec37376c0c42c6401d8bdf8f.tar.gz
pw-darwin-dbace80f4239d777ec37376c0c42c6401d8bdf8f.tar.zst
pw-darwin-dbace80f4239d777ec37376c0c42c6401d8bdf8f.zip
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 <bouceklubos AT gmail.com> Obtained from: DragonflyBSD 2020c8fec4168a5020f984a093224fade3074b25
Diffstat (limited to 'chpass')
-rw-r--r--chpass/chpass.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/chpass/chpass.c b/chpass/chpass.c
index 9f9be53..74c96be 100644
--- a/chpass/chpass.c
+++ b/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 = "";