Skip to content
Permalink
Browse files

ldap: fix OOM error on missing query string

- Allow missing queries, don't return NO_MEMORY error in such a case.

It is acceptable for there to be no specified query string, for example:

curl ldap://ldap.forumsys.com

A regression bug in 1b443a7 caused this issue.

This is a partial fix for #4261.

Bug: #4261 (comment)
Reported-by: Jojojov@users.noreply.github.com
Analyzed-by: Samuel Surtees

Closes #4467
  • Loading branch information...
nico-abram authored and jay committed Oct 5, 2019
1 parent df85b86 commit 8bb3a95ce1577e2c8282e7d1c2830bde87cf5c3b
Showing with 10 additions and 8 deletions.
  1. +10 −8 lib/ldap.c
@@ -844,10 +844,10 @@ static bool split_str(char *str, char ***out, size_t *count)
static int _ldap_url_parse2(const struct connectdata *conn, LDAPURLDesc *ludp)
{
int rc = LDAP_SUCCESS;
char *path;
char *query;
char *p;
char *q;
char *path;
char *q = NULL;
char *query = NULL;
size_t i;

if(!conn->data ||
@@ -865,11 +865,13 @@ static int _ldap_url_parse2(const struct connectdata *conn, LDAPURLDesc *ludp)
if(!path)
return LDAP_NO_MEMORY;

/* Duplicate the query */
q = query = strdup(conn->data->state.up.query);
if(!query) {
free(path);
return LDAP_NO_MEMORY;
/* Duplicate the query if present */
if(conn->data->state.up.query) {
q = query = strdup(conn->data->state.up.query);
if(!query) {
free(path);
return LDAP_NO_MEMORY;
}
}

/* Parse the DN (Distinguished Name) */

0 comments on commit 8bb3a95

Please sign in to comment.
You can’t perform that action at this time.