]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-31122: ssl.wrap_socket() now raises ssl.SSLEOFError rather than OSError when...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sat, 15 Aug 2020 17:42:36 +0000 (10:42 -0700)
committerGitHub <noreply@github.com>
Sat, 15 Aug 2020 17:42:36 +0000 (10:42 -0700)
[bpo-31122](): ssl.wrap_socket() now raises ssl.SSLEOFError rather than OSError when peer closes connection during TLS negotiation

Reproducer: http://tiny.cc/f4ztnz (tiny url because some bot keeps renaming b.p.o.-nnn as bpo links)
(cherry picked from commit 495bd035662fda29639f9d52bb6baebea31d72fa)

Co-authored-by: Dima Tisnek <dimaqq@gmail.com>
Misc/NEWS.d/next/Library/2020-03-11-07-44-06.bpo-31122.zIQ80l.rst [new file with mode: 0644]
Modules/_ssl.c

diff --git a/Misc/NEWS.d/next/Library/2020-03-11-07-44-06.bpo-31122.zIQ80l.rst b/Misc/NEWS.d/next/Library/2020-03-11-07-44-06.bpo-31122.zIQ80l.rst
new file mode 100644 (file)
index 0000000..2e70f7a
--- /dev/null
@@ -0,0 +1 @@
+ssl.wrap_socket() now raises ssl.SSLEOFError rather than OSError when peer closes connection during TLS negotiation
\ No newline at end of file
index 1944393e548908675f774b472f95d4a44a93c191..e6dda298cbe25ac437973e82608857747707be33 100644 (file)
@@ -807,10 +807,11 @@ PySSL_SetError(PySSLSocket *sslsock, int ret, const char *filename, int lineno)
                         errno = err.c;
                         return PyErr_SetFromErrno(PyExc_OSError);
                     }
-                    Py_INCREF(s);
-                    s->errorhandler();
-                    Py_DECREF(s);
-                    return NULL;
+                    else {
+                        p = PY_SSL_ERROR_EOF;
+                        type = PySSLEOFErrorObject;
+                        errstr = "EOF occurred in violation of protocol";
+                    }
                 } else { /* possible? */
                     p = PY_SSL_ERROR_SYSCALL;
                     type = PySSLSyscallErrorObject;