ppp(8): Fix various bugs in NOPAM section of auth_CheckPasswd

* pw is not initialized before use
* success is returned if crypt(3) errors

These bugs were introduced in r231994, which attempted to adopt DragonflyBSD
f4a9869feb646aafe72de6e5d61051a023a02676.  The original author of the
Dragonfly change also noticed these mistakes and filed the PR.

PR:		222620
Submitted by:	Lubos Boucek <bouceklubos AT gmail.com>
Obtained from:	DragonflyBSD f4a9869feb646aafe72de6e5d61051a023a02676
This commit is contained in:
Conrad Meyer 2017-10-02 23:14:29 +00:00
parent eb3d4ccc48
commit af3b49ef41
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=324225

View File

@ -125,13 +125,19 @@ auth_CheckPasswd(const char *name, const char *data, const char *key)
#ifdef NOPAM
/* Then look up the real password database */
struct passwd *pw;
int result;
int result = 0;
char *cryptpw;
pw = getpwnam(name);
if (pw) {
cryptpw = crypt(key, pw->pw_passwd);
result = (cryptpw != NULL) && !strcmp(cryptpw, pw->pw_passwd);
}
cryptpw = crypt(key, pw->pw_passwd);
result = (pw = getpwnam(name)) &&
(cryptpw == NULL || !strcmp(cryptpw, pw->pw_passwd));
endpwent();
return result;
#else /* !NOPAM */
/* Then consult with PAM. */