]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Fix a problem with the attributes passed to ldap_search
authorFrédéric Marchal <fmarchal@users.sourceforge.net>
Thu, 3 Feb 2011 14:02:18 +0000 (14:02 +0000)
committerFrédéric Marchal <fmarchal@users.sourceforge.net>
Thu, 3 Feb 2011 14:02:18 +0000 (14:02 +0000)
The attributes list passed to ldap_search must be terminated by a NULL
pointer. That wasn't the case in sarg and was likely responsible for a
segfault. It should be fixed now.

usertab.c

index add44323121a32db1842ddd8cb2c49150daa4441..4bbd9ccab7f8652cdc835e0af8130137e15ae58c 100644 (file)
--- a/usertab.c
+++ b/usertab.c
@@ -190,7 +190,7 @@ static void get_ldap_name(const char *userlogin,char *mappedname,int namelen)
        int i;
        int slen;
        int rc;
-       char *attrs[1];
+       char *attrs[2];
 
        searched_in_cache = search_in_cache(userlogin);
        if (searched_in_cache!=NULL) {
@@ -226,6 +226,7 @@ static void get_ldap_name(const char *userlogin,char *mappedname,int namelen)
 
        /* Search record(s) in LDAP base */
        attrs[0]=LDAPTargetAttr;
+       attrs[1]=NULL;
        rc= ldap_search_ext_s(ldap_handle, LDAPBaseSearch, LDAP_SCOPE_SUBTREE, filtersearch, attrs, 0, NULL, NULL, NULL, -1, &result);
        if (rc != LDAP_SUCCESS) {
                debuga(_("LDAP search failed: %s\n"), ldap_err2string(rc));