Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5db60aa

Browse files
committed
merge 3.5 (closes #25672)
2 parents 2900995 + 3b1a8b3 commit 5db60aa

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ Core and Builtins
128128
Library
129129
-------
130130

131+
- Issue #25672: In the ssl module, enable the SSL_MODE_RELEASE_BUFFERS mode
132+
option if it is safe to do so.
133+
131134
- Issue #22570: Add 'path' attribute to pathlib.Path objects,
132135
returning the same as str(), to make it more similar to DirEntry.
133136
Library code can now write getattr(p, 'path', p) to get the path as

Modules/_ssl.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2219,6 +2219,7 @@ _ssl__SSLContext_impl(PyTypeObject *type, int proto_version)
22192219
PySSLContext *self;
22202220
long options;
22212221
SSL_CTX *ctx = NULL;
2222+
unsigned long libver;
22222223

22232224
PySSL_BEGIN_ALLOW_THREADS
22242225
if (proto_version == PY_SSL_VERSION_TLS1)
@@ -2281,6 +2282,22 @@ _ssl__SSLContext_impl(PyTypeObject *type, int proto_version)
22812282
options |= SSL_OP_NO_SSLv3;
22822283
SSL_CTX_set_options(self->ctx, options);
22832284

2285+
#if defined(SSL_MODE_RELEASE_BUFFERS)
2286+
/* Set SSL_MODE_RELEASE_BUFFERS. This potentially greatly reduces memory
2287+
usage for no cost at all. However, don't do this for OpenSSL versions
2288+
between 1.0.1 and 1.0.1h or 1.0.0 and 1.0.0m, which are affected by CVE
2289+
2014-0198. I can't find exactly which beta fixed this CVE, so be
2290+
conservative and assume it wasn't fixed until release. We do this check
2291+
at runtime to avoid problems from the dynamic linker.
2292+
See #25672 for more on this. */
2293+
libver = SSLeay();
2294+
if (!(libver >= 0x10001000UL && libver < 0x1000108fUL) &&
2295+
!(libver >= 0x10000000UL && libver < 0x100000dfUL)) {
2296+
SSL_CTX_set_mode(self->ctx, SSL_MODE_RELEASE_BUFFERS);
2297+
}
2298+
#endif
2299+
2300+
22842301
#ifndef OPENSSL_NO_ECDH
22852302
/* Allow automatic ECDH curve selection (on OpenSSL 1.0.2+), or use
22862303
prime256v1 by default. This is Apache mod_ssl's initialization

0 commit comments

Comments
 (0)