Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Fixed a use-after-free in :mod:`ssl` when ``SSL_new()`` returns NULL in
``newPySSLSocket()``. The error was reported via a dangling pointer after the
object had already been freed.
2 changes: 1 addition & 1 deletion Modules/_ssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -844,8 +844,8 @@ newPySSLSocket(PySSLContext *sslctx, PySocketSockObject *sock,
self->ssl = SSL_new(ctx);
PySSL_END_ALLOW_THREADS
if (self->ssl == NULL) {
_setSSLError(get_state_ctx(sslctx), NULL, 0, __FILE__, __LINE__);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For my curiosity - any benefits to moving decref further down? The only thing I can think of is if get_state_ctx begins holding (indirect / chain) references to self again through its argument, moving the decref down is appropriately defensive.

Py_DECREF(self);
_setSSLError(get_state_ctx(self), NULL, 0, __FILE__, __LINE__);
return NULL;
}
/* bpo43522 and OpenSSL < 1.1.1l: copy hostflags manually */
Expand Down
Loading