diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2023-08-26 21:35:06 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-26 21:35:06 (GMT) |
commit | 2b15536fa94d07e9e286826c23507402313ec7f4 (patch) | |
tree | bed59616b5e2b833e15cc6b10f0dccfca8faa9fb /Modules/_ssl.c | |
parent | e407cea1938b80b1d469f148a4ea65587820e3eb (diff) | |
download | cpython-2b15536fa94d07e9e286826c23507402313ec7f4.zip cpython-2b15536fa94d07e9e286826c23507402313ec7f4.tar.gz cpython-2b15536fa94d07e9e286826c23507402313ec7f4.tar.bz2 |
gh-107913: Fix possible losses of OSError error codes (GH-107930)
Functions like PyErr_SetFromErrno() and SetFromWindowsErr() should be
called immediately after using the C API which sets errno or the Windows
error code.
Diffstat (limited to 'Modules/_ssl.c')
-rw-r--r-- | Modules/_ssl.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Modules/_ssl.c b/Modules/_ssl.c index c001b87..be03325 100644 --- a/Modules/_ssl.c +++ b/Modules/_ssl.c @@ -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(); } 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__); |