From 1c8caa8b6e65e17932e78eead40b089cd5454be8 Mon Sep 17 00:00:00 2001 From: Adam Langley Date: Tue, 17 Jan 2017 12:04:40 -0800 Subject: [PATCH] crypto: freelist_max_len is gone in OpenSSL 1.1.0 The freelist_max_len member of SSL* (and the freelist itself) has been removed in OpenSSL 1.1.0. Thus this change will be necessary at some point but, for now, it makes it a little easier to build with 1.1.0 without breaking anything for previous versions of OpenSSL. PR-URL: https://github.com/nodejs/node/pull/10859 Reviewed-By: Sam Roberts Reviewed-By: Fedor Indutny Reviewed-By: Ben Noordhuis Reviewed-By: James M Snell Reviewed-By: Shigeki Ohtsu --- lib/_tls_common.js | 4 +++- src/node_crypto.cc | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/_tls_common.js b/lib/_tls_common.js index 9cb70453860484..e161a484866f01 100644 --- a/lib/_tls_common.js +++ b/lib/_tls_common.js @@ -140,7 +140,9 @@ exports.createSecureContext = function createSecureContext(options, context) { } } - // Do not keep read/write buffers in free list + // Do not keep read/write buffers in free list for OpenSSL < 1.1.0. (For + // OpenSSL 1.1.0, buffers are malloced and freed without the use of a + // freelist.) if (options.singleUse) { c.singleUse = true; c.context.setFreeListLength(0); diff --git a/src/node_crypto.cc b/src/node_crypto.cc index fd464adeaa1c85..0b5a5173f61a25 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -1148,10 +1148,14 @@ void SecureContext::SetTicketKeys(const FunctionCallbackInfo& args) { void SecureContext::SetFreeListLength(const FunctionCallbackInfo& args) { +#if OPENSSL_VERSION_NUMBER < 0x10100000L && !defined(OPENSSL_IS_BORINGSSL) + // |freelist_max_len| was removed in OpenSSL 1.1.0. In that version OpenSSL + // mallocs and frees buffers directly, without the use of a freelist. SecureContext* wrap; ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder()); wrap->ctx_->freelist_max_len = args[0]->Int32Value(); +#endif }