summaryrefslogtreecommitdiff
path: root/lib/ldap.c
diff options
context:
space:
mode:
authorSamuel Surtees <ssurtees@euclideon.com>2018-12-11 20:15:15 +1000
committerDaniel Stenberg <daniel@haxx.se>2018-12-11 13:20:12 +0100
commit1b443a7c00c1e5d2d0567d440f309cba5d69096b (patch)
tree01b486448cfafc1590184dd336c4b20589f20209 /lib/ldap.c
parent3a9cb0d74d396d4cb4f987ab023d9786415a024c (diff)
downloadcurl-1b443a7c00c1e5d2d0567d440f309cba5d69096b.tar.gz
ldap: fix LDAP URL parsing regressions
- Match URL scheme with LDAP and LDAPS - Retrieve attributes, scope and filter from URL query instead Regression brought in 46e164069d1a5230 (7.62.0) Closes #3362
Diffstat (limited to 'lib/ldap.c')
-rw-r--r--lib/ldap.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/ldap.c b/lib/ldap.c
index ceaa71d08..a149f8cbc 100644
--- a/lib/ldap.c
+++ b/lib/ldap.c
@@ -839,6 +839,7 @@ static int _ldap_url_parse2(const struct connectdata *conn, LDAPURLDesc *ludp)
{
int rc = LDAP_SUCCESS;
char *path;
+ char *query;
char *p;
char *q;
size_t i;
@@ -846,7 +847,7 @@ static int _ldap_url_parse2(const struct connectdata *conn, LDAPURLDesc *ludp)
if(!conn->data ||
!conn->data->state.up.path ||
conn->data->state.up.path[0] != '/' ||
- !strcasecompare("LDAP", conn->data->state.up.scheme))
+ !strncasecompare("LDAP", conn->data->state.up.scheme, 4))
return LDAP_INVALID_SYNTAX;
ludp->lud_scope = LDAP_SCOPE_BASE;
@@ -858,11 +859,14 @@ static int _ldap_url_parse2(const struct connectdata *conn, LDAPURLDesc *ludp)
if(!path)
return LDAP_NO_MEMORY;
- /* Parse the DN (Distinguished Name) */
- q = strchr(p, '?');
- if(q)
- *q++ = '\0';
+ /* Duplicate the query */
+ q = query = strdup(conn->data->state.up.query);
+ if(!query) {
+ free(path);
+ return LDAP_NO_MEMORY;
+ }
+ /* Parse the DN (Distinguished Name) */
if(*p) {
char *dn = p;
char *unescaped;
@@ -1039,6 +1043,7 @@ static int _ldap_url_parse2(const struct connectdata *conn, LDAPURLDesc *ludp)
quit:
free(path);
+ free(query);
return rc;
}