diff options
author | Steve Holme <steve_holme@hotmail.com> | 2015-01-07 19:19:20 +0000 |
---|---|---|
committer | Steve Holme <steve_holme@hotmail.com> | 2015-01-07 20:01:27 +0000 |
commit | 4e420600c1266ee9afdab51657c76089606314e1 (patch) | |
tree | e1bd360fe1e68aee323b9cd33d0d56e62add07ef /lib/ldap.c | |
parent | 9547954978c9b8c27afac581efab18b5b910648d (diff) | |
download | curl-4e420600c1266ee9afdab51657c76089606314e1.tar.gz |
ldap: Convert DN output to UTF-8 when Unicode
Diffstat (limited to 'lib/ldap.c')
-rw-r--r-- | lib/ldap.c | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/lib/ldap.c b/lib/ldap.c index 0370d4bc6..4390a4dff 100644 --- a/lib/ldap.c +++ b/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 */ { + 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; @@ -454,13 +470,19 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done) 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); } |