]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-117310: Remove extra DECREF on "no ciphers" error path in `_ssl._SSLContext` const...
authorGregory P. Smith <greg@krypto.org>
Thu, 28 Mar 2024 10:11:58 +0000 (03:11 -0700)
committerGitHub <noreply@github.com>
Thu, 28 Mar 2024 10:11:58 +0000 (11:11 +0100)
Remove extra self DECREF on ssl "no ciphers" error path.

This doesn't come up in practice because nobody links against a broken
OpenSSL library that provides nothing.

Misc/NEWS.d/next/Library/2024-03-27-21-05-52.gh-issue-117310.Bt2wox.rst [new file with mode: 0644]
Modules/_ssl.c

diff --git a/Misc/NEWS.d/next/Library/2024-03-27-21-05-52.gh-issue-117310.Bt2wox.rst b/Misc/NEWS.d/next/Library/2024-03-27-21-05-52.gh-issue-117310.Bt2wox.rst
new file mode 100644 (file)
index 0000000..429b890
--- /dev/null
@@ -0,0 +1,4 @@
+Fixed an unlikely early & extra ``Py_DECREF`` triggered crash in :mod:`ssl`
+when creating a new ``_ssl._SSLContext`` if CPython was built implausibly such
+that the default cipher list is empty **or** the SSL library it was linked
+against reports a failure from its C ``SSL_CTX_set_cipher_list()`` API.
index f5a79dcb1ac57de1d3f83c772ae7f25a75188ef8..fbf914c43219220b86a6dc6efee9e308e4384c38 100644 (file)
@@ -3166,7 +3166,6 @@ _ssl__SSLContext_impl(PyTypeObject *type, int proto_version)
         result = SSL_CTX_set_cipher_list(ctx, "HIGH:!aNULL:!eNULL");
     }
     if (result == 0) {
-        Py_DECREF(self);
         ERR_clear_error();
         PyErr_SetString(get_state_ctx(self)->PySSLErrorObject,
                         "No cipher can be selected.");