]> granicus.if.org Git - apache/commitdiff
* mod_ldap: Correctly return all requested attribute values
authorEric Covener <covener@apache.org>
Fri, 7 Mar 2008 21:02:41 +0000 (21:02 +0000)
committerEric Covener <covener@apache.org>
Fri, 7 Mar 2008 21:02:41 +0000 (21:02 +0000)
when some attributes have a null value.

PR: 44560
Submitted by: Anders Kaseorg <anders kaseorg.com>
Reviewed by: covener

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@634821 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
modules/ldap/util_ldap.c

diff --git a/CHANGES b/CHANGES
index 92d4634b942492895356a7b6e30895f688b0b749..c34032f4c086a49e8d3d92940d56610f95e1ae2b 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,10 @@
                                                         -*- coding: utf-8 -*-
 Changes with Apache 2.3.0
 [ When backported to 2.2.x, remove entry from this file ]
+  *) mod_ldap: Correctly return all requested attribute values
+     when some attributes have a null value. 
+     PR 44560 [Anders Kaseorg <anders kaseorg.com>]
 
   *) core: check symlink ownership if both FollowSymlinks and
      SymlinksIfOwnerMatch are set [Nick Kew]
index b87bae2e9a50401344dd479bbcd384d427e5f10a..5d41aa6f5ae568e3ef4a90162d7944d2ce5b0cf5 100644 (file)
@@ -1462,13 +1462,10 @@ static int uldap_cache_checkuserid(request_rec *r, util_ldap_connection_t *ldc,
                 /* ...and entry is valid */
                 *binddn = apr_pstrdup(r->pool, search_nodep->dn);
                 if (attrs) {
-                    int i = 0, k = 0;
-                    while (attrs[k++]);
-                    *retvals = apr_pcalloc(r->pool, sizeof(char *) * k);
-                    while (search_nodep->vals[i]) {
-                        (*retvals)[i] = apr_pstrdup(r->pool,
-                                                    search_nodep->vals[i]);
-                        i++;
+                    int i;
+                    *retvals = apr_pcalloc(r->pool, sizeof(char *) * search_nodep->numvals);
+                    for (i = 0; i < search_nodep->numvals; i++) {
+                        (*retvals)[i] = apr_pstrdup(r->pool, search_nodep->vals[i]);
                     }
                 }
                 LDAP_CACHE_UNLOCK();
@@ -1712,13 +1709,10 @@ static int uldap_cache_getuserdn(request_rec *r, util_ldap_connection_t *ldc,
                 /* ...and entry is valid */
                 *binddn = apr_pstrdup(r->pool, search_nodep->dn);
                 if (attrs) {
-                    int i = 0, k = 0;
-                    while (attrs[k++]);
-                    *retvals = apr_pcalloc(r->pool, sizeof(char *) * k);
-                    while (search_nodep->vals[i]) {
-                        (*retvals)[i] = apr_pstrdup(r->pool,
-                                                    search_nodep->vals[i]);
-                        i++;
+                    int i;
+                    *retvals = apr_pcalloc(r->pool, sizeof(char *) * search_nodep->numvals);
+                    for (i = 0; i < search_nodep->numvals; i++) {
+                        (*retvals)[i] = apr_pstrdup(r->pool, search_nodep->vals[i]);
                     }
                 }
                 LDAP_CACHE_UNLOCK();