summaryrefslogtreecommitdiffstats
path: root/Modules/_ssl.c
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2023-08-26 23:24:40 (GMT)
committerGitHub <noreply@github.com>2023-08-26 23:24:40 (GMT)
commit3e2030371723e5fb7c9ccbe83cd980ce69cabc1a (patch)
tree16a5ba8999b1440a494153cd76e5a71a779ebb28 /Modules/_ssl.c
parentbbdd8895a5aced4cd4e66a5c6e3471636f28df6b (diff)
downloadcpython-3e2030371723e5fb7c9ccbe83cd980ce69cabc1a.zip
cpython-3e2030371723e5fb7c9ccbe83cd980ce69cabc1a.tar.gz
cpython-3e2030371723e5fb7c9ccbe83cd980ce69cabc1a.tar.bz2
[3.12] gh-107913: Fix possible losses of OSError error codes (GH-107930) (#108523)
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. (cherry picked from commit 2b15536fa94d07e9e286826c23507402313ec7f4) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Diffstat (limited to 'Modules/_ssl.c')
-rw-r--r--Modules/_ssl.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/Modules/_ssl.c b/Modules/_ssl.c
index e939f95..b602eb0 100644
--- a/Modules/_ssl.c
+++ b/Modules/_ssl.c
@@ -3889,8 +3889,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__);
@@ -3910,8 +3910,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__);
@@ -4140,8 +4140,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__);
@@ -4188,8 +4188,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__);