mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 23:58:49 -05:00
ldap: Convert DN output to UTF-8 when Unicode
This commit is contained in:
parent
9547954978
commit
4e420600c1
32
lib/ldap.c
32
lib/ldap.c
@ -430,23 +430,39 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
|
|||||||
|
|
||||||
/* Get the DN and write it to the client */
|
/* Get the DN and write it to the client */
|
||||||
{
|
{
|
||||||
|
char *name;
|
||||||
|
size_t name_len;
|
||||||
#if defined(CURL_LDAP_WIN)
|
#if defined(CURL_LDAP_WIN)
|
||||||
TCHAR *dn = ldap_get_dn(server, entryIterator);
|
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
|
#else
|
||||||
char *dn = ldap_get_dn(server, entryIterator);
|
char *dn = name = ldap_get_dn(server, entryIterator);
|
||||||
size_t dn_len = strlen(dn);
|
|
||||||
#endif
|
#endif
|
||||||
|
name_len = strlen(name);
|
||||||
|
|
||||||
result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"DN: ", 4);
|
result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"DN: ", 4);
|
||||||
if(result) {
|
if(result) {
|
||||||
|
#if defined(CURL_LDAP_WIN)
|
||||||
|
Curl_unicodefree(name);
|
||||||
|
#endif
|
||||||
ldap_memfree(dn);
|
ldap_memfree(dn);
|
||||||
|
|
||||||
goto quit;
|
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(result) {
|
||||||
|
#if defined(CURL_LDAP_WIN)
|
||||||
|
Curl_unicodefree(name);
|
||||||
|
#endif
|
||||||
ldap_memfree(dn);
|
ldap_memfree(dn);
|
||||||
|
|
||||||
goto quit;
|
goto quit;
|
||||||
@ -454,13 +470,19 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
|
|||||||
|
|
||||||
result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 1);
|
result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 1);
|
||||||
if(result) {
|
if(result) {
|
||||||
|
#if defined(CURL_LDAP_WIN)
|
||||||
|
Curl_unicodefree(name);
|
||||||
|
#endif
|
||||||
ldap_memfree(dn);
|
ldap_memfree(dn);
|
||||||
|
|
||||||
goto quit;
|
goto quit;
|
||||||
}
|
}
|
||||||
|
|
||||||
dlsize += dn_len + 5;
|
dlsize += name_len + 5;
|
||||||
|
|
||||||
|
#if defined(CURL_LDAP_WIN)
|
||||||
|
Curl_unicodefree(name);
|
||||||
|
#endif
|
||||||
ldap_memfree(dn);
|
ldap_memfree(dn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user