Skip to content

Commit

Permalink
[3.11] gh-117310: Remove extra DECREF on "no ciphers" error path in `…
Browse files Browse the repository at this point in the history
…_ssl._SSLContext` constructor (GH-117309) (GH-117318)

gh-117310: Remove extra DECREF on "no ciphers" error path in `_ssl._SSLContext` constructor (GH-117309)

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.
(cherry picked from commit 8cb7d7f)

Co-authored-by: Gregory P. Smith <greg@krypto.org>
  • Loading branch information
miss-islington and gpshead committed Mar 28, 2024
1 parent c703b7b commit 65a0923
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
@@ -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.
1 change: 0 additions & 1 deletion Modules/_ssl.c
Expand Up @@ -3165,7 +3165,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.");
Expand Down

0 comments on commit 65a0923

Please sign in to comment.