From e7ee1ccf4596a37a2278e523d0da7652ab43a42c Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 3 May 2004 15:01:34 +0000 Subject: Gisle fixed the problem with ldap_search_s() fails with "filter error": a case of using 'lud_filter' after freeing 'lud_dn'. --- lib/ldap.c | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) (limited to 'lib') diff --git a/lib/ldap.c b/lib/ldap.c index 2c1d118d7..223c3fb55 100644 --- a/lib/ldap.c +++ b/lib/ldap.c @@ -60,12 +60,6 @@ #define _MPRINTF_REPLACE /* use our functions only */ #include -/* WLdcap.dll's ldap_search_s() return filter error with CURLDEBUG !? - */ -#ifdef WIN32 -#undef CURLDEBUG -#endif - #ifdef CURLDEBUG #include "memdebug.h" #endif @@ -78,7 +72,7 @@ #endif #ifndef LDAP_SIZELIMIT_EXCEEDED -#define LDAP_SIZELIMIT_EXCEEDED -1 +#define LDAP_SIZELIMIT_EXCEEDED 4 #endif #define DLOPEN_MODE RTLD_LAZY /*! assume all dlopen() implementations have @@ -426,8 +420,6 @@ static char **split_str (char *str) for (i = 2, s = strchr(str,','); s; i++) s = strchr(++s,','); - LDAP_TRACE(("split_str: %d strings\n", i)); - res = calloc(i, sizeof(char*)); if (!res) return NULL; @@ -445,16 +437,6 @@ static bool unescape_elements (LDAPURLDesc *ludp) { int i; - if (ludp->lud_dn) { - char *dn = ludp->lud_dn; - char *new_dn = curl_unescape(dn, 0); - - free(dn); - if (!new_dn) - return (FALSE); - ludp->lud_dn = new_dn; - } - if (ludp->lud_filter) { ludp->lud_filter = curl_unescape(ludp->lud_filter, 0); if (!ludp->lud_filter) @@ -472,6 +454,16 @@ static bool unescape_elements (LDAPURLDesc *ludp) if (!ludp->lud_exts[i]) return (FALSE); } + + if (ludp->lud_dn) { + char *dn = ludp->lud_dn; + char *new_dn = curl_unescape(dn, 0); + + free(dn); + if (!new_dn) + return (FALSE); + ludp->lud_dn = new_dn; + } return (TRUE); } @@ -500,8 +492,6 @@ static int _ldap_url_parse2 (const struct connectdata *conn, LDAPURLDesc *ludp) ludp->lud_port = conn->remote_port; ludp->lud_host = conn->host.name; - LDAP_TRACE (("host '%s'\n", ludp->lud_host)); - /* parse DN (Distinguished Name). */ ludp->lud_dn = strdup(conn->path+1); -- cgit v1.2.3