]> granicus.if.org Git - curl/commitdiff
ldap: Stop using wide char version of ldapp_err2string
authorJay Satiro <raysatiro@yahoo.com>
Tue, 27 Aug 2019 18:20:20 +0000 (14:20 -0400)
committerJay Satiro <raysatiro@yahoo.com>
Wed, 11 Sep 2019 06:44:47 +0000 (02:44 -0400)
Despite ldapp_err2string being documented by MS as returning a
PCHAR (char *), when UNICODE it is mapped to ldap_err2stringW and
returns PWCHAR (wchar_t *).

We have lots of code that expects ldap_err2string to return char *,
most of it failf used like this:

failf(data, "LDAP local: Some error: %s", ldap_err2string(rc));

Closes https://github.com/curl/curl/pull/4272

lib/ldap.c

index fd31faa3e734993937b7dcb0fa97776f402f3813..d7d90fea7228f31f50c4bfe7a9154052dc104725 100644 (file)
@@ -119,6 +119,12 @@ static void _ldap_free_urldesc(LDAPURLDesc *ludp);
   #define LDAP_TRACE(x)   Curl_nop_stmt
 #endif
 
+#if defined(USE_WIN32_LDAP) && defined(ldap_err2string)
+/* Use ansi error strings in UNICODE builds */
+#undef ldap_err2string
+#define ldap_err2string ldap_err2stringA
+#endif
+
 
 static CURLcode Curl_ldap(struct connectdata *conn, bool *done);