-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
bpo-32533: Fixed thread-safety of error handling in _ssl. #7158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -455,20 +459,19 @@ static PyTypeObject PySSLSocket_Type; | |||
static PyTypeObject PySSLMemoryBIO_Type; | |||
static PyTypeObject PySSLSession_Type; | |||
|
|||
static inline _PySSLError _PySSL_errno(int failed, const SSL *ssl, int retcode) | |||
{ | |||
_PySSLError err = { 0 }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC that's not safe in C code. You are allocating a struct on the stack and then return the stack allocated struct to the caller. Once you return to the caller, the stack allocated memory becomes invalid and may be reused in another function call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It returns a copy, not a pointer.
When you're done making the requested changes, leave the comment: |
I have made the requested changes; please review again (not really, but I answered the comment) |
Thanks for making the requested changes! @tiran: please review the changes made to this pull request. |
@tiran, will you time to review the changes you requested? |
Thanks @zooba for the PR 🌮🎉.. I'm working now to backport this PR to: 3.6, 3.7. |
) (cherry picked from commit c6fd1c1) Co-authored-by: Steve Dower <steve.dower@microsoft.com>
GH-9363 is a backport of this pull request to the 3.7 branch. |
Sorry, @zooba, I could not cleanly backport this to |
GH-9365 is a backport of this pull request to the 3.6 branch. |
https://bugs.python.org/issue32533