diff options
author | Howard Chu <hyc@symas.com> | 2018-03-18 18:13:27 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2018-03-23 23:58:25 +0100 |
commit | b6e484dc36a2681c0991a274398f917e74517053 (patch) | |
tree | 0be0a138abe45be077b679d70860a0996719fed2 /lib/openldap.c | |
parent | 22e56194e30b43fb0ffccf500ca9eadeb8c1842e (diff) | |
download | curl-b6e484dc36a2681c0991a274398f917e74517053.tar.gz |
openldap: fix for NULL return from ldap_get_attribute_ber()
Closes #2399
Diffstat (limited to 'lib/openldap.c')
-rw-r--r-- | lib/openldap.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/lib/openldap.c b/lib/openldap.c index 187c89994..c6cb79434 100644 --- a/lib/openldap.c +++ b/lib/openldap.c @@ -536,7 +536,7 @@ static ssize_t ldap_recv(struct connectdata *conn, int sockindex, char *buf, data->req.bytecount += bv.bv_len + 5; for(rc = ldap_get_attribute_ber(li->ld, ent, ber, &bv, &bvals); - (rc == LDAP_SUCCESS) && bvals; + rc == LDAP_SUCCESS; rc = ldap_get_attribute_ber(li->ld, ent, ber, &bv, &bvals)) { int i; @@ -548,6 +548,27 @@ static ssize_t ldap_recv(struct connectdata *conn, int sockindex, char *buf, else binary = 0; + if(bvals == NULL) { + writeerr = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\t", 1); + if(writeerr) { + *err = writeerr; + 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 *)":\n", 2); + if(writeerr) { + *err = writeerr; + return -1; + } + data->req.bytecount += bv.bv_len + 3; + continue; + } + for(i = 0; bvals[i].bv_val != NULL; i++) { int binval = 0; writeerr = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\t", 1); |