Hoist the getpwnam() call outside the first if/else block in

pam_sm_chauthtok().  Set user = getlogin() inside the true
branch so that it is initialized for the following PAM_LOG()
call.  This is how it is done in pam_sm_authenticate().

Reported by:	Coverity
CID:		272498
MFC after:	1 week
This commit is contained in:
Don Lewis 2016-05-16 08:34:17 +00:00
parent bba8dcbcd3
commit 653d2f366d

View file

@ -278,13 +278,13 @@ pam_sm_chauthtok(pam_handle_t *pamh, int flags,
int pfd, tfd, retval;
if (openpam_get_option(pamh, PAM_OPT_AUTH_AS_SELF))
pwd = getpwnam(getlogin());
user = getlogin();
else {
retval = pam_get_user(pamh, &user, NULL);
if (retval != PAM_SUCCESS)
return (retval);
pwd = getpwnam(user);
}
pwd = getpwnam(user);
if (pwd == NULL)
return (PAM_AUTHTOK_RECOVERY_ERR);