]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
pam: Check for null upwd from getpwnam_r
authorAndrew Deason <adeason@sinenomine.net>
Wed, 13 Apr 2011 16:10:52 +0000 (11:10 -0500)
committerDerrick Brashear <shadow@dementix.org>
Fri, 16 Dec 2011 11:00:22 +0000 (03:00 -0800)
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>
src/pam/afs_auth.c
src/pam/afs_password.c
src/pam/afs_setcred.c

index 53d05ad2132c06864710ff51d9f50dfe99c497ef..6e68640ac4da69b8f24417d922c1240bb5dcfbfb 100644 (file)
@@ -183,7 +183,7 @@ pam_sm_authenticate(pam_handle_t * pamh, int flags, int argc,
     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);
     }
index ff4a8717bc38edf8bad54c8c07f2fcef535cdc10..afd801965161cb5c36a3e15c2763a2a41cbe4deb 100644 (file)
@@ -127,7 +127,7 @@ pam_sm_chauthtok(pam_handle_t * pamh, int flags, int argc, const char **argv)
     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);
     }
index 850ba672c3de412ca005401a5ccc66e56ccfd933..573445d196513ccf00d5b749e62b5c38c0ee41c1 100644 (file)
@@ -163,7 +163,7 @@ pam_sm_setcred(pam_handle_t * pamh, int flags, int argc, const char **argv)
     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);
     }