mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 15:48:49 -05:00
ldap: Fixed Unicode usage for all Win32 builds
Otherwise, the fixes in the previous commits would only be applicable to IDN and SSPI based builds and not others such as OpenSSL with LDAP enabled.
This commit is contained in:
parent
f6b168de4c
commit
ea93252ef1
@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@ -22,7 +22,8 @@
|
||||
|
||||
#include "curl_setup.h"
|
||||
|
||||
#if defined(USE_WIN32_IDN) || (defined(USE_WINDOWS_SSPI) && defined(UNICODE))
|
||||
#if defined(USE_WIN32_IDN) || ((defined(USE_WINDOWS_SSPI) || \
|
||||
defined(CURL_LDAP_WIN)) && defined(UNICODE))
|
||||
|
||||
/*
|
||||
* MultiByte conversions using Windows kernel32 library.
|
||||
@ -79,4 +80,4 @@ char *Curl_convert_wchar_to_UTF8(const wchar_t *str_w)
|
||||
return str_utf8;
|
||||
}
|
||||
|
||||
#endif /* USE_WIN32_IDN || (USE_WINDOWS_SSPI && UNICODE) */
|
||||
#endif /* USE_WIN32_IDN || ((USE_WINDOWS_SSPI || CURL_LDAP_WIN) && UNICODE) */
|
||||
|
@ -7,7 +7,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@ -23,7 +23,8 @@
|
||||
***************************************************************************/
|
||||
#include "curl_setup.h"
|
||||
|
||||
#if defined(USE_WIN32_IDN) || (defined(USE_WINDOWS_SSPI) && defined(UNICODE))
|
||||
#if defined(USE_WIN32_IDN) || ((defined(USE_WINDOWS_SSPI) || \
|
||||
defined(CURL_LDAP_WIN)) && defined(UNICODE))
|
||||
|
||||
/*
|
||||
* MultiByte conversions using Windows kernel32 library.
|
||||
@ -32,10 +33,11 @@
|
||||
wchar_t *Curl_convert_UTF8_to_wchar(const char *str_utf8);
|
||||
char *Curl_convert_wchar_to_UTF8(const wchar_t *str_w);
|
||||
|
||||
#endif /* USE_WIN32_IDN || (USE_WINDOWS_SSPI && UNICODE) */
|
||||
#endif /* USE_WIN32_IDN || ((USE_WINDOWS_SSPI || CURL_LDAP_WIN) && UNICODE) */
|
||||
|
||||
|
||||
#if defined(USE_WIN32_IDN) || defined(USE_WINDOWS_SSPI)
|
||||
#if defined(USE_WIN32_IDN) || defined(USE_WINDOWS_SSPI) || \
|
||||
defined(CURL_LDAP_WIN)
|
||||
|
||||
/*
|
||||
* Macros Curl_convert_UTF8_to_tchar(), Curl_convert_tchar_to_UTF8()
|
||||
@ -85,6 +87,6 @@ typedef union {
|
||||
|
||||
#endif /* UNICODE */
|
||||
|
||||
#endif /* USE_WIN32_IDN || USE_WINDOWS_SSPI */
|
||||
#endif /* USE_WIN32_IDN || USE_WINDOWS_SSPI || CURL_LDAP_WIN */
|
||||
|
||||
#endif /* HEADER_CURL_MULTIBYTE_H */
|
||||
|
36
lib/ldap.c
36
lib/ldap.c
@ -81,8 +81,7 @@
|
||||
typedef struct {
|
||||
char *lud_host;
|
||||
int lud_port;
|
||||
#if defined(CURL_LDAP_WIN) && \
|
||||
(defined(USE_WIN32_IDN) || defined(USE_WINDOWS_SSPI))
|
||||
#if defined(CURL_LDAP_WIN)
|
||||
TCHAR *lud_dn;
|
||||
TCHAR **lud_attrs;
|
||||
#else
|
||||
@ -90,8 +89,7 @@ typedef struct {
|
||||
char **lud_attrs;
|
||||
#endif
|
||||
int lud_scope;
|
||||
#if defined(CURL_LDAP_WIN) && \
|
||||
(defined(USE_WIN32_IDN) || defined(USE_WINDOWS_SSPI))
|
||||
#if defined(CURL_LDAP_WIN)
|
||||
TCHAR *lud_filter;
|
||||
#else
|
||||
char *lud_filter;
|
||||
@ -196,8 +194,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
|
||||
#ifdef LDAP_OPT_NETWORK_TIMEOUT
|
||||
struct timeval ldap_timeout = {10,0}; /* 10 sec connection/search timeout */
|
||||
#endif
|
||||
#if defined(CURL_LDAP_WIN) && \
|
||||
(defined(USE_WIN32_IDN) || defined(USE_WINDOWS_SSPI))
|
||||
#if defined(CURL_LDAP_WIN)
|
||||
TCHAR *host = NULL;
|
||||
TCHAR *user = NULL;
|
||||
TCHAR *passwd = NULL;
|
||||
@ -229,8 +226,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
|
||||
infof(data, "LDAP local: trying to establish %s connection\n",
|
||||
ldap_ssl ? "encrypted" : "cleartext");
|
||||
|
||||
#if defined(CURL_LDAP_WIN) && \
|
||||
(defined(USE_WIN32_IDN) || defined(USE_WINDOWS_SSPI))
|
||||
#if defined(CURL_LDAP_WIN)
|
||||
host = Curl_convert_UTF8_to_tchar(conn->host.name);
|
||||
if(!host) {
|
||||
result = CURLE_OUT_OF_MEMORY;
|
||||
@ -425,8 +421,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
|
||||
entryIterator;
|
||||
entryIterator = ldap_next_entry(server, entryIterator), num++) {
|
||||
BerElement *ber = NULL;
|
||||
#if defined(CURL_LDAP_WIN) && \
|
||||
(defined(USE_WIN32_IDN) || defined(USE_WINDOWS_SSPI))
|
||||
#if defined(CURL_LDAP_WIN)
|
||||
TCHAR *attribute;
|
||||
#else
|
||||
char *attribute; /*! suspicious that this isn't 'const' */
|
||||
@ -435,8 +430,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
|
||||
|
||||
/* Get the DN and write it to the client */
|
||||
{
|
||||
#if defined(CURL_LDAP_WIN) && \
|
||||
(defined(USE_WIN32_IDN) || defined(USE_WINDOWS_SSPI))
|
||||
#if defined(CURL_LDAP_WIN)
|
||||
TCHAR *dn = ldap_get_dn(server, entryIterator);
|
||||
size_t dn_len = _tcslen(dn);
|
||||
#else
|
||||
@ -474,8 +468,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
|
||||
for(attribute = ldap_first_attribute(server, entryIterator, &ber);
|
||||
attribute;
|
||||
attribute = ldap_next_attribute(server, entryIterator, ber)) {
|
||||
#if defined(CURL_LDAP_WIN) && \
|
||||
(defined(USE_WIN32_IDN) || defined(USE_WINDOWS_SSPI))
|
||||
#if defined(CURL_LDAP_WIN)
|
||||
size_t attr_len = _tcslen(attribute);
|
||||
#else
|
||||
size_t attr_len = strlen(attribute);
|
||||
@ -612,8 +605,7 @@ quit:
|
||||
ldapssl_client_deinit();
|
||||
#endif /* HAVE_LDAP_SSL && CURL_HAS_NOVELL_LDAPSDK */
|
||||
|
||||
#if defined(CURL_LDAP_WIN) && \
|
||||
(defined(USE_WIN32_IDN) || defined(USE_WINDOWS_SSPI))
|
||||
#if defined(CURL_LDAP_WIN)
|
||||
Curl_unicodefree(passwd);
|
||||
Curl_unicodefree(user);
|
||||
Curl_unicodefree(host);
|
||||
@ -753,8 +745,7 @@ static int _ldap_url_parse2 (const struct connectdata *conn, LDAPURLDesc *ludp)
|
||||
goto quit;
|
||||
}
|
||||
|
||||
#if defined(CURL_LDAP_WIN) && \
|
||||
(defined(USE_WIN32_IDN) || defined(USE_WINDOWS_SSPI))
|
||||
#if defined(CURL_LDAP_WIN)
|
||||
/* Convert the unescapped string to a tchar */
|
||||
ludp->lud_dn = Curl_convert_UTF8_to_tchar(unescapped);
|
||||
|
||||
@ -792,8 +783,7 @@ static int _ldap_url_parse2 (const struct connectdata *conn, LDAPURLDesc *ludp)
|
||||
}
|
||||
|
||||
/* Allocate our array (+1 for the NULL entry) */
|
||||
#if defined(CURL_LDAP_WIN) && \
|
||||
(defined(USE_WIN32_IDN) || defined(USE_WINDOWS_SSPI))
|
||||
#if defined(CURL_LDAP_WIN)
|
||||
ludp->lud_attrs = calloc(count + 1, sizeof(TCHAR *));
|
||||
#else
|
||||
ludp->lud_attrs = calloc(count + 1, sizeof(char *));
|
||||
@ -821,8 +811,7 @@ static int _ldap_url_parse2 (const struct connectdata *conn, LDAPURLDesc *ludp)
|
||||
goto quit;
|
||||
}
|
||||
|
||||
#if defined(CURL_LDAP_WIN) && \
|
||||
(defined(USE_WIN32_IDN) || defined(USE_WINDOWS_SSPI))
|
||||
#if defined(CURL_LDAP_WIN)
|
||||
/* Convert the unescapped string to a tchar */
|
||||
ludp->lud_attrs[i] = Curl_convert_UTF8_to_tchar(unescapped);
|
||||
|
||||
@ -888,8 +877,7 @@ static int _ldap_url_parse2 (const struct connectdata *conn, LDAPURLDesc *ludp)
|
||||
goto quit;
|
||||
}
|
||||
|
||||
#if defined(CURL_LDAP_WIN) && \
|
||||
(defined(USE_WIN32_IDN) || defined(USE_WINDOWS_SSPI))
|
||||
#if defined(CURL_LDAP_WIN)
|
||||
/* Convert the unescapped string to a tchar */
|
||||
ludp->lud_filter = Curl_convert_UTF8_to_tchar(unescapped);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user