aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2014-12-10 00:41:32 +0100
committerDaniel Stenberg <daniel@haxx.se>2014-12-10 00:41:32 +0100
commit086ad79970f3cd0463558bfb69122f6acdc9d2da (patch)
treeee53aaf82804ec1bdca87cfec2491198d59df7ef
parent0e8158eabc48f0bdb2bb7241e45407cec92b8ad4 (diff)
ldap: check Curl_client_write() return codes
There might be one or two memory leaks left in the error paths.
-rw-r--r--lib/ldap.c48
1 files changed, 37 insertions, 11 deletions
diff --git a/lib/ldap.c b/lib/ldap.c
index 14437c3b5..96521bf21 100644
--- a/lib/ldap.c
+++ b/lib/ldap.c
@@ -384,9 +384,17 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
char *dn = ldap_get_dn(server, entryIterator);
int i;
- Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"DN: ", 4);
- Curl_client_write(conn, CLIENTWRITE_BODY, (char *)dn, 0);
- Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 1);
+ result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"DN: ", 4);
+ if(result)
+ goto quit;
+
+ result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)dn, 0);
+ if(result)
+ goto quit;
+
+ result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 1);
+ if(result)
+ goto quit;
dlsize += strlen(dn)+5;
@@ -397,9 +405,18 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
if(vals != NULL) {
for(i = 0; (vals[i] != NULL); i++) {
- Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\t", 1);
- Curl_client_write(conn, CLIENTWRITE_BODY, (char *) attribute, 0);
- Curl_client_write(conn, CLIENTWRITE_BODY, (char *)": ", 2);
+ result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\t", 1);
+ if(result)
+ goto quit;
+
+ result = Curl_client_write(conn, CLIENTWRITE_BODY,
+ (char *)attribute, 0);
+ if(result)
+ goto quit;
+
+ result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)": ", 2);
+ if(result)
+ goto quit;
dlsize += strlen(attribute)+3;
if((strlen(attribute) > 7) &&
@@ -422,24 +439,33 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
goto quit;
}
if(val_b64_sz > 0) {
- Curl_client_write(conn, CLIENTWRITE_BODY, val_b64, val_b64_sz);
+ result = Curl_client_write(conn, CLIENTWRITE_BODY, val_b64,
+ val_b64_sz);
free(val_b64);
+ if(result)
+ goto quit;
dlsize += val_b64_sz;
}
}
else {
- Curl_client_write(conn, CLIENTWRITE_BODY, vals[i]->bv_val,
- vals[i]->bv_len);
+ result = Curl_client_write(conn, CLIENTWRITE_BODY, vals[i]->bv_val,
+ vals[i]->bv_len);
+ if(result)
+ goto quit;
dlsize += vals[i]->bv_len;
}
- Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 0);
+ result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 0);
+ if(result)
+ goto quit;
dlsize++;
}
/* Free memory used to store values */
ldap_value_free_len(vals);
}
- Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 1);
+ result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 1);
+ if(result)
+ goto quit;
dlsize++;
Curl_pgrsSetDownloadCounter(data, dlsize);
ldap_memfree(attribute);