openssl: check the return value of BIO_new_mem_buf()

Closes #8233
This commit is contained in:
xkernel 2022-01-06 21:29:02 +08:00 committed by Daniel Stenberg
parent 60080202bb
commit 30aea2b1ed
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View File

@ -3953,9 +3953,20 @@ static CURLcode servercert(struct Curl_easy *data,
/* e.g. match issuer name with provided issuer certificate */ /* e.g. match issuer name with provided issuer certificate */
if(SSL_CONN_CONFIG(issuercert) || SSL_CONN_CONFIG(issuercert_blob)) { if(SSL_CONN_CONFIG(issuercert) || SSL_CONN_CONFIG(issuercert_blob)) {
if(SSL_CONN_CONFIG(issuercert_blob)) if(SSL_CONN_CONFIG(issuercert_blob)) {
fp = BIO_new_mem_buf(SSL_CONN_CONFIG(issuercert_blob)->data, fp = BIO_new_mem_buf(SSL_CONN_CONFIG(issuercert_blob)->data,
(int)SSL_CONN_CONFIG(issuercert_blob)->len); (int)SSL_CONN_CONFIG(issuercert_blob)->len);
if(!fp) {
failf(data,
"BIO_new_mem_buf NULL, " OSSL_PACKAGE
" error %s",
ossl_strerror(ERR_get_error(), error_buffer,
sizeof(error_buffer)) );
X509_free(backend->server_cert);
backend->server_cert = NULL;
return CURLE_OUT_OF_MEMORY;
}
}
else { else {
fp = BIO_new(BIO_s_file()); fp = BIO_new(BIO_s_file());
if(!fp) { if(!fp) {