summaryrefslogtreecommitdiffstats
path: root/Utilities/cmcurl/lib/openldap.c
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-08-03 18:26:53 (GMT)
committerBrad King <brad.king@kitware.com>2016-08-03 18:26:53 (GMT)
commitf53f4a8a2d215dac634effea575a27e000dfcb29 (patch)
tree5782e71da9e12ab6081e47f8eaf8eeb908e1428a /Utilities/cmcurl/lib/openldap.c
parente1c11352f231ae310339cd539ed59cb302bd4dbe (diff)
parent202adcfe056681109fe61569ecdb3bd69f0b4f97 (diff)
downloadCMake-f53f4a8a2d215dac634effea575a27e000dfcb29.zip
CMake-f53f4a8a2d215dac634effea575a27e000dfcb29.tar.gz
CMake-f53f4a8a2d215dac634effea575a27e000dfcb29.tar.bz2
Merge branch 'upstream-curl' into update-curl
* upstream-curl: curl 2016-08-03 (f2cb3a01)
Diffstat (limited to 'Utilities/cmcurl/lib/openldap.c')
-rw-r--r--Utilities/cmcurl/lib/openldap.c109
1 files changed, 68 insertions, 41 deletions
diff --git a/Utilities/cmcurl/lib/openldap.c b/Utilities/cmcurl/lib/openldap.c
index bee552f..4b8cfb9 100644
--- a/Utilities/cmcurl/lib/openldap.c
+++ b/Utilities/cmcurl/lib/openldap.c
@@ -6,11 +6,11 @@
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2010, Howard Chu, <hyc@openldap.org>
- * Copyright (C) 2011 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2011 - 2016, 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
- * are also available at http://curl.haxx.se/docs/copyright.html.
+ * are also available at https://curl.haxx.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
@@ -46,9 +46,8 @@
#include "curl_ldap.h"
#include "curl_base64.h"
#include "connect.h"
+/* The last 3 #include files should be in this order */
#include "curl_printf.h"
-
-/* The last #include files should be: */
#include "curl_memory.h"
#include "memdebug.h"
@@ -151,7 +150,7 @@ static CURLcode ldap_setup_connection(struct connectdata *conn)
{
ldapconninfo *li;
LDAPURLDesc *lud;
- struct SessionHandle *data=conn->data;
+ struct Curl_easy *data=conn->data;
int rc, proto;
CURLcode status;
@@ -189,7 +188,7 @@ static Sockbuf_IO ldapsb_tls;
static CURLcode ldap_connect(struct connectdata *conn, bool *done)
{
ldapconninfo *li = conn->proto.generic;
- struct SessionHandle *data = conn->data;
+ struct Curl_easy *data = conn->data;
int rc, proto = LDAP_VERSION3;
char hosturl[1024];
char *ptr;
@@ -227,7 +226,7 @@ static CURLcode ldap_connect(struct connectdata *conn, bool *done)
static CURLcode ldap_connecting(struct connectdata *conn, bool *done)
{
ldapconninfo *li = conn->proto.generic;
- struct SessionHandle *data = conn->data;
+ struct Curl_easy *data = conn->data;
LDAPMessage *msg = NULL;
struct timeval tv = {0, 1}, *tvp;
int rc, err;
@@ -353,7 +352,7 @@ static CURLcode ldap_do(struct connectdata *conn, bool *done)
int rc = 0;
LDAPURLDesc *ludp = NULL;
int msgid;
- struct SessionHandle *data=conn->data;
+ struct Curl_easy *data=conn->data;
connkeep(conn, "OpenLDAP do");
@@ -416,7 +415,7 @@ static ssize_t ldap_recv(struct connectdata *conn, int sockindex, char *buf,
size_t len, CURLcode *err)
{
ldapconninfo *li = conn->proto.generic;
- struct SessionHandle *data = conn->data;
+ struct Curl_easy *data = conn->data;
ldapreqinfo *lr = data->req.protop;
int rc, ret;
LDAPMessage *msg = NULL;
@@ -446,6 +445,7 @@ static ssize_t ldap_recv(struct connectdata *conn, int sockindex, char *buf,
ent = ldap_next_message(li->ld, ent)) {
struct berval bv, *bvals, **bvp = &bvals;
int binary = 0, msgtype;
+ CURLcode writeerr;
msgtype = ldap_msgtype(ent);
if(msgtype == LDAP_RES_SEARCH_RESULT) {
@@ -485,18 +485,24 @@ static ssize_t ldap_recv(struct connectdata *conn, int sockindex, char *buf,
*err = CURLE_RECV_ERROR;
return -1;
}
- *err = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"DN: ", 4);
- if(*err)
+ writeerr = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"DN: ", 4);
+ if(writeerr) {
+ *err = writeerr;
return -1;
+ }
- *err = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)bv.bv_val,
- bv.bv_len);
- if(*err)
+ writeerr = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)bv.bv_val,
+ bv.bv_len);
+ if(writeerr) {
+ *err = writeerr;
return -1;
+ }
- *err = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 1);
- if(*err)
+ writeerr = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 1);
+ if(writeerr) {
+ *err = writeerr;
return -1;
+ }
data->req.bytecount += bv.bv_len + 5;
for(rc = ldap_get_attribute_ber(li->ld, ent, ber, &bv, bvp);
@@ -513,18 +519,24 @@ static ssize_t ldap_recv(struct connectdata *conn, int sockindex, char *buf,
for(i=0; bvals[i].bv_val != NULL; i++) {
int binval = 0;
- *err = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\t", 1);
- if(*err)
- return -1;
-
- *err = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)bv.bv_val,
- bv.bv_len);
- if(*err)
+ writeerr = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\t", 1);
+ if(writeerr) {
+ *err = writeerr;
return -1;
+ }
- *err = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)":", 1);
- if(*err)
- return -1;
+ writeerr = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)bv.bv_val,
+ bv.bv_len);
+ if(writeerr) {
+ *err = writeerr;
+ return -1;
+ }
+
+ writeerr = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)":", 1);
+ if(writeerr) {
+ *err = writeerr;
+ return -1;
+ }
data->req.bytecount += bv.bv_len + 2;
if(!binary) {
@@ -558,47 +570,62 @@ static ssize_t ldap_recv(struct connectdata *conn, int sockindex, char *buf,
*err = error;
return -1;
}
- *err = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)": ", 2);
- if(*err)
+ writeerr = Curl_client_write(conn, CLIENTWRITE_BODY,
+ (char *)": ", 2);
+ if(writeerr) {
+ *err = writeerr;
return -1;
+ }
data->req.bytecount += 2;
if(val_b64_sz > 0) {
- *err = Curl_client_write(conn, CLIENTWRITE_BODY, val_b64,
+ writeerr = Curl_client_write(conn, CLIENTWRITE_BODY, val_b64,
val_b64_sz);
- if(*err)
+ if(writeerr) {
+ *err = writeerr;
return -1;
+ }
free(val_b64);
data->req.bytecount += val_b64_sz;
}
}
else {
- *err = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)" ", 1);
- if(*err)
+ writeerr = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)" ", 1);
+ if(writeerr) {
+ *err = writeerr;
return -1;
+ }
- *err = Curl_client_write(conn, CLIENTWRITE_BODY, bvals[i].bv_val,
- bvals[i].bv_len);
- if(*err)
+ writeerr = Curl_client_write(conn, CLIENTWRITE_BODY, bvals[i].bv_val,
+ bvals[i].bv_len);
+ if(writeerr) {
+ *err = writeerr;
return -1;
+ }
data->req.bytecount += bvals[i].bv_len + 1;
}
- *err = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 0);
- if(*err)
+ writeerr = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 0);
+ if(writeerr) {
+ *err = writeerr;
return -1;
+ }
data->req.bytecount++;
}
ber_memfree(bvals);
- *err = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 0);
- if(*err)
+ writeerr = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 0);
+ if(writeerr) {
+ *err = writeerr;
return -1;
+ }
data->req.bytecount++;
}
- *err = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 0);
- if(*err)
+ writeerr = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 0);
+ if(writeerr) {
+ *err = writeerr;
return -1;
+ }
data->req.bytecount++;
ber_free(ber, 0);
}