The POSIX getpwnam_r can yield a NULL struct passwd pointer even when
the returned error code is 0 (in particular, when the requested entry
is not found). Just add a check for a null upwd to make sure we don't
dereference a NULL pointer.
Reviewed-on: http://gerrit.openafs.org/4469
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
(cherry picked from commit
fbb4c6115b9af9c52ee06fa9c979a3f4195ad342)
Change-Id: I9a8bccba7b6ecbce393ea149270e5c61ebadd05c
Reviewed-on: http://gerrit.openafs.org/6290
Tested-by: Derrick Brashear <shadow@dementix.org>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
if (i == 0) /* getpwnam_r success */
upwd = &unix_pwd;
#endif /* else AFS_HPUX110_ENV */
- if (ignore_uid && i == 0 && upwd->pw_uid <= ignore_uid_id) {
+ if (ignore_uid && i == 0 && upwd && upwd->pw_uid <= ignore_uid_id) {
pam_afs_syslog(LOG_INFO, PAMAFS_IGNORINGROOT, user);
RET(PAM_AUTH_ERR);
}
if (i == 0) /* getpwnam_r success */
upwd = &unix_pwd;
#endif /* else AFS_HPUX110_ENV */
- if (ignore_root && i == 0 && upwd->pw_uid == 0) {
+ if (ignore_root && i == 0 && upwd && upwd->pw_uid == 0) {
pam_afs_syslog(LOG_INFO, PAMAFS_IGNORINGROOT, user);
RET(PAM_AUTH_ERR);
}
if (i == 0) /* getpwnam_r success */
upwd = &unix_pwd;
#endif /* AFS_HPUX110_ENV */
- if (ignore_uid && i == 0 && upwd->pw_uid <= ignore_uid_id) {
+ if (ignore_uid && i == 0 && upwd && upwd->pw_uid <= ignore_uid_id) {
pam_afs_syslog(LOG_INFO, PAMAFS_IGNORINGROOT, user);
RET(PAM_AUTH_ERR);
}