mirror of
https://github.com/curl/curl.git
synced 2026-07-24 18:17:16 +03:00
sectransp: do verify_cert without memdup for blobs
Since the information is then already stored in memory, this can avoid an extra set of malloc + free calls. Closes #12679
This commit is contained in:
parent
24ae4a07f3
commit
dd0f680fc0
1 changed files with 6 additions and 5 deletions
|
|
@ -2370,13 +2370,12 @@ static CURLcode verify_cert(struct Curl_cfilter *cf,
|
|||
CURLcode result;
|
||||
unsigned char *certbuf;
|
||||
size_t buflen;
|
||||
bool free_certbuf = FALSE;
|
||||
|
||||
if(ca_info_blob) {
|
||||
CURL_TRC_CF(data, cf, "verify_peer, CA from config blob");
|
||||
certbuf = (unsigned char *)Curl_memdup0(ca_info_blob->data,
|
||||
buflen = ca_info_blob->len);
|
||||
if(!certbuf)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
certbuf = ca_info_blob->data;
|
||||
buflen = ca_info_blob->len;
|
||||
}
|
||||
else if(cafile) {
|
||||
CURL_TRC_CF(data, cf, "verify_peer, CA from file '%s'", cafile);
|
||||
|
|
@ -2384,12 +2383,14 @@ static CURLcode verify_cert(struct Curl_cfilter *cf,
|
|||
failf(data, "SSL: failed to read or invalid CA certificate");
|
||||
return CURLE_SSL_CACERT_BADFILE;
|
||||
}
|
||||
free_certbuf = TRUE;
|
||||
}
|
||||
else
|
||||
return CURLE_SSL_CACERT_BADFILE;
|
||||
|
||||
result = verify_cert_buf(cf, data, certbuf, buflen, ctx);
|
||||
free(certbuf);
|
||||
if(free_certbuf)
|
||||
free(certbuf);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue