base64: fix Curl_base64_encode and Curl_base64_decode interfaces
Previous interfaces for these libcurl internal functions did not allow to tell apart a legitimate zero size result from an error condition. These functions now return a CURLcode indicating function success or otherwise specific error. Output size is returned using a pointer argument. All usage of these two functions, and others closely related, has been adapted to the new interfaces. Relative error and OOM handling adapted or added where missing. Unit test 1302 also adapted.
This commit is contained in:
@@ -544,12 +544,21 @@ static ssize_t ldap_recv(struct connectdata *conn, int sockindex, char *buf,
|
||||
}
|
||||
}
|
||||
if(binary || binval) {
|
||||
char *val_b64;
|
||||
char *val_b64 = NULL;
|
||||
size_t val_b64_sz = 0;
|
||||
/* Binary value, encode to base64. */
|
||||
size_t val_b64_sz = Curl_base64_encode(data,
|
||||
bvals[i].bv_val,
|
||||
bvals[i].bv_len,
|
||||
&val_b64);
|
||||
CURLcode error = Curl_base64_encode(data,
|
||||
bvals[i].bv_val,
|
||||
bvals[i].bv_len,
|
||||
&val_b64,
|
||||
&val_b64_sz);
|
||||
if(error) {
|
||||
ber_memfree(bvals);
|
||||
ber_free(ber, 0);
|
||||
ldap_msgfree(result);
|
||||
*err = error;
|
||||
return -1;
|
||||
}
|
||||
Curl_client_write(conn, CLIENTWRITE_BODY, (char *)": ", 2);
|
||||
data->req.bytecount += 2;
|
||||
if(val_b64_sz > 0) {
|
||||
|
||||
Reference in New Issue
Block a user