mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
[ruby/openssl] ssl: fix potential memory leak in SSLContext#setup
If SSL_CTX_add_extra_chain_cert() fails, the refcount of x509 must be
handled by the caller. This should only occur due to a malloc failure
inside the function.
80bcf727dc
This commit is contained in:
parent
b43c7cf8c4
commit
06a56a7ffc
1 changed files with 3 additions and 2 deletions
|
@ -430,8 +430,9 @@ ossl_sslctx_add_extra_chain_cert_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, arg))
|
|||
|
||||
GetSSLCTX(arg, ctx);
|
||||
x509 = DupX509CertPtr(i);
|
||||
if(!SSL_CTX_add_extra_chain_cert(ctx, x509)){
|
||||
ossl_raise(eSSLError, NULL);
|
||||
if (!SSL_CTX_add_extra_chain_cert(ctx, x509)) {
|
||||
X509_free(x509);
|
||||
ossl_raise(eSSLError, "SSL_CTX_add_extra_chain_cert");
|
||||
}
|
||||
|
||||
return i;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue