summaryrefslogtreecommitdiff
path: root/Utilities/cmcurl/lib/ldap.c
diff options
context:
space:
mode:
Diffstat (limited to 'Utilities/cmcurl/lib/ldap.c')
-rw-r--r--Utilities/cmcurl/lib/ldap.c72
1 files changed, 25 insertions, 47 deletions
diff --git a/Utilities/cmcurl/lib/ldap.c b/Utilities/cmcurl/lib/ldap.c
index 512def659c..0a1f02d5b4 100644
--- a/Utilities/cmcurl/lib/ldap.c
+++ b/Utilities/cmcurl/lib/ldap.c
@@ -9,7 +9,7 @@
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
- * are also available at https://curl.haxx.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -150,6 +150,7 @@ const struct Curl_handler Curl_handler_ldap = {
ZERO_NULL, /* connection_check */
PORT_LDAP, /* defport */
CURLPROTO_LDAP, /* protocol */
+ CURLPROTO_LDAP, /* family */
PROTOPT_NONE /* flags */
};
@@ -176,6 +177,7 @@ const struct Curl_handler Curl_handler_ldaps = {
ZERO_NULL, /* connection_check */
PORT_LDAPS, /* defport */
CURLPROTO_LDAPS, /* protocol */
+ CURLPROTO_LDAP, /* family */
PROTOPT_SSL /* flags */
};
#endif
@@ -257,6 +259,13 @@ static int ldap_win_bind(struct connectdata *conn, LDAP *server,
}
#endif /* #if defined(USE_WIN32_LDAP) */
+#if defined(USE_WIN32_LDAP)
+#define FREE_ON_WINLDAP(x) curlx_unicodefree(x)
+#else
+#define FREE_ON_WINLDAP(x)
+#endif
+
+
static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
{
CURLcode result = CURLE_OK;
@@ -463,9 +472,6 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
}
#ifdef USE_WIN32_LDAP
ldap_set_option(server, LDAP_OPT_PROTOCOL_VERSION, &ldap_proto);
-#endif
-
-#ifdef USE_WIN32_LDAP
rc = ldap_win_bind(conn, server, user, passwd);
#else
rc = ldap_simple_bind_s(server, user, passwd);
@@ -507,7 +513,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
#if defined(USE_WIN32_LDAP)
TCHAR *attribute;
#else
- char *attribute; /*! suspicious that this isn't 'const' */
+ char *attribute;
#endif
int i;
@@ -532,30 +538,22 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"DN: ", 4);
if(result) {
-#if defined(USE_WIN32_LDAP)
- curlx_unicodefree(name);
-#endif
+ FREE_ON_WINLDAP(name);
ldap_memfree(dn);
-
goto quit;
}
result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *) name,
name_len);
if(result) {
-#if defined(USE_WIN32_LDAP)
- curlx_unicodefree(name);
-#endif
+ FREE_ON_WINLDAP(name);
ldap_memfree(dn);
-
goto quit;
}
result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 1);
if(result) {
-#if defined(USE_WIN32_LDAP)
- curlx_unicodefree(name);
-#endif
+ FREE_ON_WINLDAP(name);
ldap_memfree(dn);
goto quit;
@@ -563,9 +561,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
dlsize += name_len + 5;
-#if defined(USE_WIN32_LDAP)
- curlx_unicodefree(name);
-#endif
+ FREE_ON_WINLDAP(name);
ldap_memfree(dn);
}
@@ -596,9 +592,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\t", 1);
if(result) {
ldap_value_free_len(vals);
-#if defined(USE_WIN32_LDAP)
- curlx_unicodefree(attr);
-#endif
+ FREE_ON_WINLDAP(attr);
ldap_memfree(attribute);
if(ber)
ber_free(ber, 0);
@@ -610,9 +604,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
(char *) attr, attr_len);
if(result) {
ldap_value_free_len(vals);
-#if defined(USE_WIN32_LDAP)
- curlx_unicodefree(attr);
-#endif
+ FREE_ON_WINLDAP(attr);
ldap_memfree(attribute);
if(ber)
ber_free(ber, 0);
@@ -623,9 +615,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)": ", 2);
if(result) {
ldap_value_free_len(vals);
-#if defined(USE_WIN32_LDAP)
- curlx_unicodefree(attr);
-#endif
+ FREE_ON_WINLDAP(attr);
ldap_memfree(attribute);
if(ber)
ber_free(ber, 0);
@@ -645,9 +635,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
&val_b64_sz);
if(result) {
ldap_value_free_len(vals);
-#if defined(USE_WIN32_LDAP)
- curlx_unicodefree(attr);
-#endif
+ FREE_ON_WINLDAP(attr);
ldap_memfree(attribute);
if(ber)
ber_free(ber, 0);
@@ -661,9 +649,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
free(val_b64);
if(result) {
ldap_value_free_len(vals);
-#if defined(USE_WIN32_LDAP)
- curlx_unicodefree(attr);
-#endif
+ FREE_ON_WINLDAP(attr);
ldap_memfree(attribute);
if(ber)
ber_free(ber, 0);
@@ -679,9 +665,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
vals[i]->bv_len);
if(result) {
ldap_value_free_len(vals);
-#if defined(USE_WIN32_LDAP)
- curlx_unicodefree(attr);
-#endif
+ FREE_ON_WINLDAP(attr);
ldap_memfree(attribute);
if(ber)
ber_free(ber, 0);
@@ -695,9 +679,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 1);
if(result) {
ldap_value_free_len(vals);
-#if defined(USE_WIN32_LDAP)
- curlx_unicodefree(attr);
-#endif
+ FREE_ON_WINLDAP(attr);
ldap_memfree(attribute);
if(ber)
ber_free(ber, 0);
@@ -713,9 +695,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
}
/* Free the attribute as we are done with it */
-#if defined(USE_WIN32_LDAP)
- curlx_unicodefree(attr);
-#endif
+ FREE_ON_WINLDAP(attr);
ldap_memfree(attribute);
result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 1);
@@ -745,9 +725,7 @@ quit:
ldapssl_client_deinit();
#endif /* HAVE_LDAP_SSL && CURL_HAS_NOVELL_LDAPSDK */
-#if defined(USE_WIN32_LDAP)
- curlx_unicodefree(host);
-#endif
+ FREE_ON_WINLDAP(host);
/* no data to transfer */
Curl_setup_transfer(data, -1, -1, FALSE, -1);
@@ -945,7 +923,7 @@ static int _ldap_url_parse2(const struct connectdata *conn, LDAPURLDesc *ludp)
char *unescaped;
CURLcode result;
- LDAP_TRACE(("attr[%d] '%s'\n", i, attributes[i]));
+ LDAP_TRACE(("attr[%zu] '%s'\n", i, attributes[i]));
/* Unescape the attribute */
result = Curl_urldecode(conn->data, attributes[i], 0, &unescaped, NULL,