openssl: check the return value of BIO_new()

Closes #8078
This commit is contained in:
x2018 2021-12-01 11:20:33 +08:00 committed by Daniel Stenberg
parent 470d546048
commit 34294a65b2
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2

View file

@ -3570,6 +3570,9 @@ static CURLcode get_cert_chain(struct Curl_easy *data,
}
mem = BIO_new(BIO_s_mem());
if(!mem) {
return CURLE_OUT_OF_MEMORY;
}
for(i = 0; i < (int)numcerts; i++) {
ASN1_INTEGER *num;
@ -3866,6 +3869,15 @@ static CURLcode servercert(struct Curl_easy *data,
BIO *mem = BIO_new(BIO_s_mem());
struct ssl_backend_data *backend = connssl->backend;
if(!mem) {
failf(data,
"BIO_new return NULL, " OSSL_PACKAGE
" error %s",
ossl_strerror(ERR_get_error(), error_buffer,
sizeof(error_buffer)) );
return CURLE_OUT_OF_MEMORY;
}
if(data->set.ssl.certinfo)
/* we've been asked to gather certificate info! */
(void)get_cert_chain(data, connssl);