1
0
mirror of https://github.com/moparisthebest/curl synced 2024-08-13 17:03:50 -04:00

openssl: free mem_buf in error path

To fix a memory-leak.

Closes #6267
This commit is contained in:
Daniel Stenberg 2020-11-30 17:36:42 +01:00
parent 0d75bf9ae9
commit 2d4d012a49
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View File

@ -2731,33 +2731,33 @@ static CURLcode ossl_connect_step1(struct connectdata *conn, int sockindex)
if(ssl_cert || ssl_cert_blob || ssl_cert_type) {
BIO *ssl_cert_bio = NULL;
BIO *ssl_key_bio = NULL;
int result_cert_stuff;
if(ssl_cert_blob) {
/* the typecast of blob->len is fine since it is guaranteed to never be
larger than CURL_MAX_INPUT_LENGTH */
ssl_cert_bio = BIO_new_mem_buf(ssl_cert_blob->data,
(int)ssl_cert_blob->len);
if(!ssl_cert_bio)
return CURLE_SSL_CERTPROBLEM;
result = CURLE_OUT_OF_MEMORY;
}
if(SSL_SET_OPTION(key_blob)) {
if(!result && SSL_SET_OPTION(key_blob)) {
ssl_key_bio = BIO_new_mem_buf(SSL_SET_OPTION(key_blob)->data,
(int)SSL_SET_OPTION(key_blob)->len);
if(!ssl_key_bio)
return CURLE_SSL_CERTPROBLEM;
result = CURLE_OUT_OF_MEMORY;
}
result_cert_stuff = cert_stuff(conn, backend->ctx,
if(!result &&
!cert_stuff(conn, backend->ctx,
ssl_cert, ssl_cert_bio, ssl_cert_type,
SSL_SET_OPTION(key), ssl_key_bio,
SSL_SET_OPTION(key_type), SSL_SET_OPTION(key_passwd));
SSL_SET_OPTION(key_type), SSL_SET_OPTION(key_passwd)))
result = CURLE_SSL_CERTPROBLEM;
if(ssl_cert_bio)
BIO_free(ssl_cert_bio);
if(ssl_key_bio)
BIO_free(ssl_key_bio);
if(!result_cert_stuff) {
if(result)
/* failf() is already done in cert_stuff() */
return CURLE_SSL_CERTPROBLEM;
}
return result;
}
ciphers = SSL_CONN_CONFIG(cipher_list);