-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
gh-107913: Fix possible losses of OSError error codes #107930
Changes from all commits
29f6f36
0485db3
ba06d0a
695dbdb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Fix possible losses of ``errno`` and ``winerror`` values in :exc:`OSError` | ||
exceptions if they were cleared or modified by the cleanup code before | ||
creating the exception object. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3914,8 +3914,8 @@ _ssl__SSLContext_load_cert_chain_impl(PySSLContext *self, PyObject *certfile, | |
/* the password callback has already set the error information */ | ||
} | ||
else if (errno != 0) { | ||
ERR_clear_error(); | ||
PyErr_SetFromErrno(PyExc_OSError); | ||
ERR_clear_error(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this function related to errno? Or is it specific to ssl and it leaves errno unchanged? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do not know, but it is better to be on safe side. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I'm fine with this change. |
||
} | ||
else { | ||
_setSSLError(get_state_ctx(self), NULL, 0, __FILE__, __LINE__); | ||
|
@@ -3935,8 +3935,8 @@ _ssl__SSLContext_load_cert_chain_impl(PySSLContext *self, PyObject *certfile, | |
/* the password callback has already set the error information */ | ||
} | ||
else if (errno != 0) { | ||
ERR_clear_error(); | ||
PyErr_SetFromErrno(PyExc_OSError); | ||
ERR_clear_error(); | ||
} | ||
else { | ||
_setSSLError(get_state_ctx(self), NULL, 0, __FILE__, __LINE__); | ||
|
@@ -4165,8 +4165,8 @@ _ssl__SSLContext_load_verify_locations_impl(PySSLContext *self, | |
PySSL_END_ALLOW_THREADS | ||
if (r != 1) { | ||
if (errno != 0) { | ||
ERR_clear_error(); | ||
PyErr_SetFromErrno(PyExc_OSError); | ||
ERR_clear_error(); | ||
} | ||
else { | ||
_setSSLError(get_state_ctx(self), NULL, 0, __FILE__, __LINE__); | ||
|
@@ -4213,8 +4213,8 @@ _ssl__SSLContext_load_dh_params(PySSLContext *self, PyObject *filepath) | |
PySSL_END_ALLOW_THREADS | ||
if (dh == NULL) { | ||
if (errno != 0) { | ||
ERR_clear_error(); | ||
PyErr_SetFromErrnoWithFilenameObject(PyExc_OSError, filepath); | ||
ERR_clear_error(); | ||
} | ||
else { | ||
_setSSLError(get_state_ctx(self), NULL, 0, __FILE__, __LINE__); | ||
|
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.
fd_is_own = 1;
changes the code in the error label, it's unclear to me if your change is correct or not.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 only has effect if
self->fd >= 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.
Ok, I see. This change is non-trivial, I preferred to double check.