From e8fa0671a48fe862ea1acc251e6c17ef4132165f Mon Sep 17 00:00:00 2001 From: Sam Roberts Date: Wed, 22 May 2019 21:07:07 -0700 Subject: [PATCH] tls: destroy trace BIO instead of leaking it Fixes: https://github.com/nodejs/node/issues/27636#issuecomment-491343214 PR-URL: https://github.com/nodejs/node/pull/27834 Reviewed-By: James M Snell Reviewed-By: Ben Noordhuis Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: Rich Trott --- src/tls_wrap.cc | 4 ++-- src/tls_wrap.h | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/tls_wrap.cc b/src/tls_wrap.cc index 69293ad906e614..2b0da3e3bcf4b4 100644 --- a/src/tls_wrap.cc +++ b/src/tls_wrap.cc @@ -939,9 +939,9 @@ void TLSWrap::EnableTrace( #if HAVE_SSL_TRACE if (wrap->ssl_) { - BIO* b = BIO_new_fp(stderr, BIO_NOCLOSE | BIO_FP_TEXT); + wrap->bio_trace_.reset(BIO_new_fp(stderr, BIO_NOCLOSE | BIO_FP_TEXT)); SSL_set_msg_callback(wrap->ssl_.get(), SSL_trace); - SSL_set_msg_callback_arg(wrap->ssl_.get(), b); + SSL_set_msg_callback_arg(wrap->ssl_.get(), wrap->bio_trace_.get()); } #endif } diff --git a/src/tls_wrap.h b/src/tls_wrap.h index b866bbb7af122e..e2ff68205730c6 100644 --- a/src/tls_wrap.h +++ b/src/tls_wrap.h @@ -193,6 +193,8 @@ class TLSWrap : public AsyncWrap, private: static void GetWriteQueueSize( const v8::FunctionCallbackInfo& info); + + crypto::BIOPointer bio_trace_; }; } // namespace node