diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2020-08-15 17:44:57 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-15 17:44:57 (GMT) |
commit | fc8ffe27b6f29d67b76fb2ef57466c95af5a9f82 (patch) | |
tree | d1a1161f2b1cb3cb7bdd1537b0130b1d83c8b1f5 | |
parent | 31bc45c4b275a0bfcb46e5a115276f1daa814523 (diff) | |
download | cpython-fc8ffe27b6f29d67b76fb2ef57466c95af5a9f82.zip cpython-fc8ffe27b6f29d67b76fb2ef57466c95af5a9f82.tar.gz cpython-fc8ffe27b6f29d67b76fb2ef57466c95af5a9f82.tar.bz2 |
bpo-31122: ssl.wrap_socket() now raises ssl.SSLEOFError rather than OSError when peer closes connection during TLS negotiation (GH-18772)
[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>
-rw-r--r-- | Misc/NEWS.d/next/Library/2020-03-11-07-44-06.bpo-31122.zIQ80l.rst | 1 | ||||
-rw-r--r-- | Modules/_ssl.c | 9 |
2 files changed, 6 insertions, 4 deletions
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 index 0000000..2e70f7a --- /dev/null +++ b/Misc/NEWS.d/next/Library/2020-03-11-07-44-06.bpo-31122.zIQ80l.rst @@ -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 diff --git a/Modules/_ssl.c b/Modules/_ssl.c index a8c339d..28796b3 100644 --- a/Modules/_ssl.c +++ b/Modules/_ssl.c @@ -805,10 +805,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; |