Skip to content

Commit

Permalink
ldap: Convert DN output to UTF-8 when Unicode
Browse files Browse the repository at this point in the history
  • Loading branch information
captain-caveman2k committed Jan 7, 2015
1 parent 9547954 commit 4e42060
Showing 1 changed file with 27 additions and 5 deletions.
32 changes: 27 additions & 5 deletions lib/ldap.c
Expand Up @@ -430,37 +430,59 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)

/* Get the DN and write it to the client */
{
char *name;
size_t name_len;
#if defined(CURL_LDAP_WIN)
TCHAR *dn = ldap_get_dn(server, entryIterator);
size_t dn_len = _tcslen(dn);
name = Curl_convert_tchar_to_UTF8(dn);
if(!name) {
ldap_memfree(dn);

result = CURLE_OUT_OF_MEMORY;

goto quit;
}
#else
char *dn = ldap_get_dn(server, entryIterator);
size_t dn_len = strlen(dn);
char *dn = name = ldap_get_dn(server, entryIterator);
#endif
name_len = strlen(name);

result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"DN: ", 4);
if(result) {
#if defined(CURL_LDAP_WIN)
Curl_unicodefree(name);
#endif
ldap_memfree(dn);

goto quit;
}

result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *) dn, dn_len);
result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *) name,
name_len);
if(result) {
#if defined(CURL_LDAP_WIN)
Curl_unicodefree(name);
#endif
ldap_memfree(dn);

goto quit;
}

result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 1);
if(result) {
#if defined(CURL_LDAP_WIN)
Curl_unicodefree(name);
#endif
ldap_memfree(dn);

goto quit;
}

dlsize += dn_len + 5;
dlsize += name_len + 5;

#if defined(CURL_LDAP_WIN)
Curl_unicodefree(name);
#endif
ldap_memfree(dn);
}

Expand Down

0 comments on commit 4e42060

Please sign in to comment.