mirror of
https://github.com/curl/curl.git
synced 2026-04-14 22:41:40 +03:00
ldap: do not base64 encode zero length string
Reported-by: Joshua Rogers Closes #18602
This commit is contained in:
parent
b4922b1295
commit
44a586472b
1 changed files with 18 additions and 16 deletions
34
lib/ldap.c
34
lib/ldap.c
|
|
@ -634,22 +634,9 @@ static CURLcode ldap_do(struct Curl_easy *data, bool *done)
|
|||
if((attr_len > 7) &&
|
||||
(strcmp(";binary", attr + (attr_len - 7)) == 0)) {
|
||||
/* Binary attribute, encode to base64. */
|
||||
result = curlx_base64_encode(vals[i]->bv_val, vals[i]->bv_len,
|
||||
&val_b64, &val_b64_sz);
|
||||
if(result) {
|
||||
ldap_value_free_len(vals);
|
||||
FREE_ON_WINLDAP(attr);
|
||||
ldap_memfree(attribute);
|
||||
if(ber)
|
||||
ber_free(ber, 0);
|
||||
|
||||
goto quit;
|
||||
}
|
||||
|
||||
if(val_b64_sz > 0) {
|
||||
result = Curl_client_write(data, CLIENTWRITE_BODY, val_b64,
|
||||
val_b64_sz);
|
||||
free(val_b64);
|
||||
if(vals[i]->bv_len) {
|
||||
result = curlx_base64_encode(vals[i]->bv_val, vals[i]->bv_len,
|
||||
&val_b64, &val_b64_sz);
|
||||
if(result) {
|
||||
ldap_value_free_len(vals);
|
||||
FREE_ON_WINLDAP(attr);
|
||||
|
|
@ -659,6 +646,21 @@ static CURLcode ldap_do(struct Curl_easy *data, bool *done)
|
|||
|
||||
goto quit;
|
||||
}
|
||||
|
||||
if(val_b64_sz > 0) {
|
||||
result = Curl_client_write(data, CLIENTWRITE_BODY, val_b64,
|
||||
val_b64_sz);
|
||||
free(val_b64);
|
||||
if(result) {
|
||||
ldap_value_free_len(vals);
|
||||
FREE_ON_WINLDAP(attr);
|
||||
ldap_memfree(attribute);
|
||||
if(ber)
|
||||
ber_free(ber, 0);
|
||||
|
||||
goto quit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue