diff options
author | Arthur de Jong <arthur@arthurdejong.org> | 2011-03-09 22:32:30 +0000 |
---|---|---|
committer | Arthur de Jong <arthur@arthurdejong.org> | 2011-03-09 22:32:30 +0000 |
commit | 42665615d2097e844db38129f926ddd24630233d (patch) | |
tree | 14aef55001ad75979006f4693b56af43e3c62764 | |
parent | 3ed326754db42ae1ae6d94d175923ef3ef663a16 (diff) |
properly handle user-not-found errors when doing authentication (CVE-2011-0438)
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-pam-ldapd@1382 ef36b2f9-881f-0410-afb5-c4e39611909c
-rw-r--r-- | nslcd/pam.c | 4 | ||||
-rw-r--r-- | nslcd/passwd.c | 14 |
2 files changed, 15 insertions, 3 deletions
diff --git a/nslcd/pam.c b/nslcd/pam.c index e9a4df4..378aa40 100644 --- a/nslcd/pam.c +++ b/nslcd/pam.c @@ -2,7 +2,7 @@ pam.c - pam processing routines Copyright (C) 2009 Howard Chu - Copyright (C) 2009, 2010 Arthur de Jong + Copyright (C) 2009, 2010, 2011 Arthur de Jong This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -105,6 +105,8 @@ static int validate_user(MYLDAP_SESSION *session,char *userdn,size_t userdnsz, entry=uid2entry(session,username,&rc); if (entry==NULL) { + if (rc==LDAP_SUCCESS) + rc=LDAP_NO_SUCH_OBJECT; log_log(LOG_WARNING,"\"%s\": user not found: %s",username,ldap_err2string(rc)); return rc; } diff --git a/nslcd/passwd.c b/nslcd/passwd.c index 9113f5d..074b805 100644 --- a/nslcd/passwd.c +++ b/nslcd/passwd.c @@ -5,7 +5,7 @@ Copyright (C) 1997-2005 Luke Howard Copyright (C) 2006 West Consulting - Copyright (C) 2006, 2007, 2008, 2009, 2010 Arthur de Jong + Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Arthur de Jong This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -300,7 +300,11 @@ MYLDAP_ENTRY *uid2entry(MYLDAP_SESSION *session,const char *uid,int *rcp) char filter[1024]; /* if it isn't a valid username, just bail out now */ if (!isvalidname(uid)) + { + if (rcp!=NULL) + *rcp=LDAP_INVALID_SYNTAX; return NULL; + } /* set up attributes (we don't need much) */ attrs[0]=attmap_passwd_uid; attrs[1]=attmap_passwd_uidNumber; @@ -311,11 +315,17 @@ MYLDAP_ENTRY *uid2entry(MYLDAP_SESSION *session,const char *uid,int *rcp) { search=myldap_search(session,base,passwd_scope,filter,attrs,rcp); if (search==NULL) + { + if ((rcp!=NULL)&&(*rcp==LDAP_SUCCESS)) + *rcp=LDAP_NO_SUCH_OBJECT; return NULL; - entry=myldap_get_entry(search,NULL); + } + entry=myldap_get_entry(search,rcp); if ((entry!=NULL)&&(entry_has_valid_uid(entry))) return entry; } + if ((rcp!=NULL)&&(*rcp==LDAP_SUCCESS)) + *rcp=LDAP_NO_SUCH_OBJECT; return NULL; } |