diff options
author | wpaul <wpaul@FreeBSD.org> | 1996-10-23 14:50:30 +0000 |
---|---|---|
committer | wpaul <wpaul@FreeBSD.org> | 1996-10-23 14:50:30 +0000 |
commit | 0450c4ad17dcd54b6be8cab5f47d733e6e00a50d (patch) | |
tree | d157761ef0a74989fae1676b088e746c2fc1ec79 /usr.bin/passwd | |
parent | a989e7ab3adeebc74c56fb507cefab2427a59411 (diff) | |
download | FreeBSD-src-0450c4ad17dcd54b6be8cab5f47d733e6e00a50d.zip FreeBSD-src-0450c4ad17dcd54b6be8cab5f47d733e6e00a50d.tar.gz |
Fix a core dump condition I discovered the other day (right
after I installed the last SNAP :). Because of the way the 'use NIS
or local?' logic is set up here, it was possible to force the use
of the NIS password changer even though the specified user didn't exist
in NIS (i.e. # passwd foo, where foo is a local-only user). In this
case, we fall intp yp_passwd() without the corresponding yp_password
structure being filled in, which leads to an NULL pointer dereference.
Also fixed the logic like I just did with chpass so that if the user
is both in NIS and the local password database, the program makes a
more sensible guess as to which one to use (if NIS is turned on in
/etc/master.passwd, then use NIS, else default to local).
Diffstat (limited to 'usr.bin/passwd')
-rw-r--r-- | usr.bin/passwd/passwd.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/usr.bin/passwd/passwd.c b/usr.bin/passwd/passwd.c index a7e2623..13113c0 100644 --- a/usr.bin/passwd/passwd.c +++ b/usr.bin/passwd/passwd.c @@ -43,7 +43,7 @@ static const char copyright[] = #ifndef lint static const char sccsid[] = "From: @(#)passwd.c 8.3 (Berkeley) 4/2/94"; static const char rcsid[] = - "$Id: passwd.c,v 1.7 1995/12/16 09:45:15 markm Exp $"; + "$Id: passwd.c,v 1.8 1996/02/23 16:08:26 wpaul Exp $"; #endif /* not lint */ #include <err.h> @@ -181,7 +181,7 @@ main(argc, argv) if (__use_yp || (iflag == NULL && rflag == NULL && uflag == NULL)) { #endif res = use_yp(uname, 0, 0); - if (res == USER_YP_ONLY || __use_yp) { + if (res == USER_YP_ONLY) { if (!use_local_passwd) { exit(yp_passwd(uname)); } else { @@ -198,7 +198,7 @@ main(argc, argv) if (__use_yp) errx(1, "unknown NIS user: %s.", uname); } else if (res == USER_YP_AND_LOCAL) { - if (!use_local_passwd) + if (!use_local_passwd && (yp_in_pw_file || __use_yp)) exit(yp_passwd(uname)); } #ifdef KERBEROS |