diff options
Diffstat (limited to 'lib/openldap.c')
-rw-r--r-- | lib/openldap.c | 81 |
1 files changed, 43 insertions, 38 deletions
diff --git a/lib/openldap.c b/lib/openldap.c index 24892ff41..e387605fe 100644 --- a/lib/openldap.c +++ b/lib/openldap.c @@ -5,8 +5,8 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * + * Copyright (C) 2011 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 2010, Howard Chu, <hyc@openldap.org> - * Copyright (C) 2011 - 2020, 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 @@ -76,12 +76,14 @@ extern int ldap_init_fd(ber_socket_t fd, int proto, const char *url, LDAP **ld); #endif -static CURLcode ldap_setup_connection(struct connectdata *conn); -static CURLcode ldap_do(struct connectdata *conn, bool *done); -static CURLcode ldap_done(struct connectdata *conn, CURLcode, bool); -static CURLcode ldap_connect(struct connectdata *conn, bool *done); -static CURLcode ldap_connecting(struct connectdata *conn, bool *done); -static CURLcode ldap_disconnect(struct connectdata *conn, bool dead); +static CURLcode ldap_setup_connection(struct Curl_easy *data, + struct connectdata *conn); +static CURLcode ldap_do(struct Curl_easy *data, bool *done); +static CURLcode ldap_done(struct Curl_easy *data, CURLcode, bool); +static CURLcode ldap_connect(struct Curl_easy *data, bool *done); +static CURLcode ldap_connecting(struct Curl_easy *data, bool *done); +static CURLcode ldap_disconnect(struct Curl_easy *data, + struct connectdata *conn, bool dead); static Curl_recv ldap_recv; @@ -169,11 +171,11 @@ struct ldapreqinfo { int nument; }; -static CURLcode ldap_setup_connection(struct connectdata *conn) +static CURLcode ldap_setup_connection(struct Curl_easy *data, + struct connectdata *conn) { struct ldapconninfo *li; LDAPURLDesc *lud; - struct Curl_easy *data = conn->data; int rc, proto; CURLcode status; @@ -205,10 +207,10 @@ static CURLcode ldap_setup_connection(struct connectdata *conn) static Sockbuf_IO ldapsb_tls; #endif -static CURLcode ldap_connect(struct connectdata *conn, bool *done) +static CURLcode ldap_connect(struct Curl_easy *data, bool *done) { + struct connectdata *conn = data->conn; struct ldapconninfo *li = conn->proto.ldapc; - struct Curl_easy *data = conn->data; int rc, proto = LDAP_VERSION3; char hosturl[1024]; char *ptr; @@ -252,10 +254,10 @@ static CURLcode ldap_connect(struct connectdata *conn, bool *done) return CURLE_OK; } -static CURLcode ldap_connecting(struct connectdata *conn, bool *done) +static CURLcode ldap_connecting(struct Curl_easy *data, bool *done) { + struct connectdata *conn = data->conn; struct ldapconninfo *li = conn->proto.ldapc; - struct Curl_easy *data = conn->data; LDAPMessage *msg = NULL; struct timeval tv = {0, 1}, *tvp; int rc, err; @@ -357,10 +359,12 @@ static CURLcode ldap_connecting(struct connectdata *conn, bool *done) return CURLE_OK; } -static CURLcode ldap_disconnect(struct connectdata *conn, bool dead_connection) +static CURLcode ldap_disconnect(struct Curl_easy *data, + struct connectdata *conn, bool dead_connection) { struct ldapconninfo *li = conn->proto.ldapc; (void) dead_connection; + (void) data; if(li) { if(li->ld) { @@ -373,15 +377,15 @@ static CURLcode ldap_disconnect(struct connectdata *conn, bool dead_connection) return CURLE_OK; } -static CURLcode ldap_do(struct connectdata *conn, bool *done) +static CURLcode ldap_do(struct Curl_easy *data, bool *done) { + struct connectdata *conn = data->conn; struct ldapconninfo *li = conn->proto.ldapc; struct ldapreqinfo *lr; CURLcode status = CURLE_OK; int rc = 0; LDAPURLDesc *ludp = NULL; int msgid; - struct Curl_easy *data = conn->data; connkeep(conn, "OpenLDAP do"); @@ -418,10 +422,11 @@ static CURLcode ldap_do(struct connectdata *conn, bool *done) return CURLE_OK; } -static CURLcode ldap_done(struct connectdata *conn, CURLcode res, +static CURLcode ldap_done(struct Curl_easy *data, CURLcode res, bool premature) { - struct ldapreqinfo *lr = conn->data->req.p.ldap; + struct connectdata *conn = data->conn; + struct ldapreqinfo *lr = data->req.p.ldap; (void)res; (void)premature; @@ -440,11 +445,11 @@ static CURLcode ldap_done(struct connectdata *conn, CURLcode res, return CURLE_OK; } -static ssize_t ldap_recv(struct connectdata *conn, int sockindex, char *buf, +static ssize_t ldap_recv(struct Curl_easy *data, int sockindex, char *buf, size_t len, CURLcode *err) { + struct connectdata *conn = data->conn; struct ldapconninfo *li = conn->proto.ldapc; - struct Curl_easy *data = conn->data; struct ldapreqinfo *lr = data->req.p.ldap; int rc, ret; LDAPMessage *msg = NULL; @@ -512,20 +517,20 @@ static ssize_t ldap_recv(struct connectdata *conn, int sockindex, char *buf, *err = CURLE_RECV_ERROR; return -1; } - writeerr = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"DN: ", 4); + writeerr = Curl_client_write(data, CLIENTWRITE_BODY, (char *)"DN: ", 4); if(writeerr) { *err = writeerr; return -1; } - writeerr = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)bv.bv_val, + writeerr = Curl_client_write(data, CLIENTWRITE_BODY, (char *)bv.bv_val, bv.bv_len); if(writeerr) { *err = writeerr; return -1; } - writeerr = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 1); + writeerr = Curl_client_write(data, CLIENTWRITE_BODY, (char *)"\n", 1); if(writeerr) { *err = writeerr; return -1; @@ -546,18 +551,18 @@ static ssize_t ldap_recv(struct connectdata *conn, int sockindex, char *buf, binary = 0; if(bvals == NULL) { - writeerr = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\t", 1); + writeerr = Curl_client_write(data, CLIENTWRITE_BODY, (char *)"\t", 1); if(writeerr) { *err = writeerr; return -1; } - writeerr = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)bv.bv_val, + writeerr = Curl_client_write(data, CLIENTWRITE_BODY, (char *)bv.bv_val, bv.bv_len); if(writeerr) { *err = writeerr; return -1; } - writeerr = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)":\n", 2); + writeerr = Curl_client_write(data, CLIENTWRITE_BODY, (char *)":\n", 2); if(writeerr) { *err = writeerr; return -1; @@ -568,20 +573,20 @@ static ssize_t ldap_recv(struct connectdata *conn, int sockindex, char *buf, for(i = 0; bvals[i].bv_val != NULL; i++) { int binval = 0; - writeerr = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\t", 1); + writeerr = Curl_client_write(data, CLIENTWRITE_BODY, (char *)"\t", 1); if(writeerr) { *err = writeerr; return -1; } - writeerr = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)bv.bv_val, + writeerr = Curl_client_write(data, CLIENTWRITE_BODY, (char *)bv.bv_val, bv.bv_len); if(writeerr) { *err = writeerr; return -1; } - writeerr = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)":", 1); + writeerr = Curl_client_write(data, CLIENTWRITE_BODY, (char *)":", 1); if(writeerr) { *err = writeerr; return -1; @@ -619,7 +624,7 @@ static ssize_t ldap_recv(struct connectdata *conn, int sockindex, char *buf, *err = error; return -1; } - writeerr = Curl_client_write(conn, CLIENTWRITE_BODY, + writeerr = Curl_client_write(data, CLIENTWRITE_BODY, (char *)": ", 2); if(writeerr) { *err = writeerr; @@ -628,7 +633,7 @@ static ssize_t ldap_recv(struct connectdata *conn, int sockindex, char *buf, data->req.bytecount += 2; if(val_b64_sz > 0) { - writeerr = Curl_client_write(conn, CLIENTWRITE_BODY, val_b64, + writeerr = Curl_client_write(data, CLIENTWRITE_BODY, val_b64, val_b64_sz); if(writeerr) { *err = writeerr; @@ -639,13 +644,13 @@ static ssize_t ldap_recv(struct connectdata *conn, int sockindex, char *buf, } } else { - writeerr = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)" ", 1); + writeerr = Curl_client_write(data, CLIENTWRITE_BODY, (char *)" ", 1); if(writeerr) { *err = writeerr; return -1; } - writeerr = Curl_client_write(conn, CLIENTWRITE_BODY, bvals[i].bv_val, + writeerr = Curl_client_write(data, CLIENTWRITE_BODY, bvals[i].bv_val, bvals[i].bv_len); if(writeerr) { *err = writeerr; @@ -654,7 +659,7 @@ static ssize_t ldap_recv(struct connectdata *conn, int sockindex, char *buf, data->req.bytecount += bvals[i].bv_len + 1; } - writeerr = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 0); + writeerr = Curl_client_write(data, CLIENTWRITE_BODY, (char *)"\n", 0); if(writeerr) { *err = writeerr; return -1; @@ -663,14 +668,14 @@ static ssize_t ldap_recv(struct connectdata *conn, int sockindex, char *buf, data->req.bytecount++; } ber_memfree(bvals); - writeerr = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 0); + writeerr = Curl_client_write(data, CLIENTWRITE_BODY, (char *)"\n", 0); if(writeerr) { *err = writeerr; return -1; } data->req.bytecount++; } - writeerr = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 0); + writeerr = Curl_client_write(data, CLIENTWRITE_BODY, (char *)"\n", 0); if(writeerr) { *err = writeerr; return -1; @@ -724,7 +729,7 @@ ldapsb_tls_read(Sockbuf_IO_Desc *sbiod, void *buf, ber_len_t len) ber_slen_t ret; CURLcode err = CURLE_RECV_ERROR; - ret = (li->recv)(conn, FIRSTSOCKET, buf, len, &err); + ret = (li->recv)(conn->data, FIRSTSOCKET, buf, len, &err); if(ret < 0 && err == CURLE_AGAIN) { SET_SOCKERRNO(EWOULDBLOCK); } @@ -739,7 +744,7 @@ ldapsb_tls_write(Sockbuf_IO_Desc *sbiod, void *buf, ber_len_t len) ber_slen_t ret; CURLcode err = CURLE_SEND_ERROR; - ret = (li->send)(conn, FIRSTSOCKET, buf, len, &err); + ret = (li->send)(conn->data, FIRSTSOCKET, buf, len, &err); if(ret < 0 && err == CURLE_AGAIN) { SET_SOCKERRNO(EWOULDBLOCK); } |