summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorx2018 <xkernel.wang@foxmail.com>2021-12-01 11:20:33 +0800
committerDaniel Stenberg <daniel@haxx.se>2021-12-01 11:51:53 +0100
commit34294a65b29b19ed3699f7cdd7ff98bdf02b1d48 (patch)
treec14bdaad203566b14dfbf21f8e543b0ef9f27434
parent470d546048e3cf88158a522204397956f3ee26d8 (diff)
downloadcurl-34294a65b29b19ed3699f7cdd7ff98bdf02b1d48.tar.gz
openssl: check the return value of BIO_new()
Closes #8078
-rw-r--r--lib/vtls/openssl.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/vtls/openssl.c b/lib/vtls/openssl.c
index 237f49878..94bfb57e7 100644
--- a/lib/vtls/openssl.c
+++ b/lib/vtls/openssl.c
@@ -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);