1
0
mirror of https://github.com/moparisthebest/curl synced 2024-11-15 14:05:03 -05:00

openldap: avoid NULL pointer dereferences

Follow-up to a59c33ceff
Reported-by: Patrick Monnerat
Fixes #6676
Closes #6780
This commit is contained in:
Daniel Stenberg 2021-03-23 09:28:07 +01:00
parent 3bbf62b5a4
commit e467ea3bd9
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View File

@ -369,6 +369,9 @@ static CURLcode ldap_disconnect(struct Curl_easy *data,
if(li) {
if(li->ld) {
Sockbuf *sb;
ldap_get_option(li->ld, LDAP_OPT_SOCKBUF, &sb);
ber_sockbuf_add_io(sb, &ldapsb_tls, LBER_SBIOD_LEVEL_TRANSPORT, NULL);
ldap_unbind_ext(li->ld, NULL, NULL);
li->ld = NULL;
}
@ -726,15 +729,19 @@ static ber_slen_t
ldapsb_tls_read(Sockbuf_IO_Desc *sbiod, void *buf, ber_len_t len)
{
struct Curl_easy *data = sbiod->sbiod_pvt;
ber_slen_t ret = 0;
if(data) {
struct connectdata *conn = data->conn;
if(conn) {
struct ldapconninfo *li = conn->proto.ldapc;
ber_slen_t ret;
CURLcode err = CURLE_RECV_ERROR;
ret = (li->recv)(data, FIRSTSOCKET, buf, len, &err);
if(ret < 0 && err == CURLE_AGAIN) {
SET_SOCKERRNO(EWOULDBLOCK);
}
}
}
return ret;
}
@ -742,15 +749,18 @@ static ber_slen_t
ldapsb_tls_write(Sockbuf_IO_Desc *sbiod, void *buf, ber_len_t len)
{
struct Curl_easy *data = sbiod->sbiod_pvt;
ber_slen_t ret = 0;
if(data) {
struct connectdata *conn = data->conn;
if(conn) {
struct ldapconninfo *li = conn->proto.ldapc;
ber_slen_t ret;
CURLcode err = CURLE_SEND_ERROR;
ret = (li->send)(data, FIRSTSOCKET, buf, len, &err);
if(ret < 0 && err == CURLE_AGAIN) {
SET_SOCKERRNO(EWOULDBLOCK);
}
}
}
return ret;
}