ldap: check Curl_client_write() return codes
There might be one or two memory leaks left in the error paths.
This commit is contained in:
Родитель
0e8158eabc
Коммит
086ad79970
48
lib/ldap.c
48
lib/ldap.c
|
@ -384,9 +384,17 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
|
||||||
char *dn = ldap_get_dn(server, entryIterator);
|
char *dn = ldap_get_dn(server, entryIterator);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"DN: ", 4);
|
result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"DN: ", 4);
|
||||||
Curl_client_write(conn, CLIENTWRITE_BODY, (char *)dn, 0);
|
if(result)
|
||||||
Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 1);
|
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;
|
dlsize += strlen(dn)+5;
|
||||||
|
|
||||||
|
@ -397,9 +405,18 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
|
||||||
|
|
||||||
if(vals != NULL) {
|
if(vals != NULL) {
|
||||||
for(i = 0; (vals[i] != NULL); i++) {
|
for(i = 0; (vals[i] != NULL); i++) {
|
||||||
Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\t", 1);
|
result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\t", 1);
|
||||||
Curl_client_write(conn, CLIENTWRITE_BODY, (char *) attribute, 0);
|
if(result)
|
||||||
Curl_client_write(conn, CLIENTWRITE_BODY, (char *)": ", 2);
|
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;
|
dlsize += strlen(attribute)+3;
|
||||||
|
|
||||||
if((strlen(attribute) > 7) &&
|
if((strlen(attribute) > 7) &&
|
||||||
|
@ -422,24 +439,33 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
|
||||||
goto quit;
|
goto quit;
|
||||||
}
|
}
|
||||||
if(val_b64_sz > 0) {
|
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);
|
free(val_b64);
|
||||||
|
if(result)
|
||||||
|
goto quit;
|
||||||
dlsize += val_b64_sz;
|
dlsize += val_b64_sz;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Curl_client_write(conn, CLIENTWRITE_BODY, vals[i]->bv_val,
|
result = Curl_client_write(conn, CLIENTWRITE_BODY, vals[i]->bv_val,
|
||||||
vals[i]->bv_len);
|
vals[i]->bv_len);
|
||||||
|
if(result)
|
||||||
|
goto quit;
|
||||||
dlsize += vals[i]->bv_len;
|
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++;
|
dlsize++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free memory used to store values */
|
/* Free memory used to store values */
|
||||||
ldap_value_free_len(vals);
|
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++;
|
dlsize++;
|
||||||
Curl_pgrsSetDownloadCounter(data, dlsize);
|
Curl_pgrsSetDownloadCounter(data, dlsize);
|
||||||
ldap_memfree(attribute);
|
ldap_memfree(attribute);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче