Skip to content

Commit 7529754

Browse files
tiranmiss-islington
authored andcommitted
[3.6] bpo-34759: Fix error handling in ssl 'unwrap()' (GH-9468) (GH-9492)
OpenSSL follows the convention that whenever you call a function, it returns an error indicator value; and if this value is negative, then you need to go look at the actual error code to see what happened. Commit c6fd1c1 introduced a small mistake in _ssl__SSLSocket_shutdown_impl: instead of checking whether the error indicator was negative, it started checking whether the actual error code was negative, and it turns out that the error codes are never negative. So the effect was that 'unwrap()' lost the ability to raise SSL errors. https://bugs.python.org/issue34759. (cherry picked from commit c0da582) Co-authored-by: Nathaniel J. Smith <njs@pobox.com> https://bugs.python.org/issue34759
1 parent d1b336e commit 7529754

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

Modules/_ssl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2407,9 +2407,9 @@ _ssl__SSLSocket_shutdown_impl(PySSLSocket *self)
24072407
break;
24082408
}
24092409

2410-
if (err.ssl < 0) {
2410+
if (ret < 0) {
24112411
Py_XDECREF(sock);
2412-
return PySSL_SetError(self, err.ssl, __FILE__, __LINE__);
2412+
return PySSL_SetError(self, ret, __FILE__, __LINE__);
24132413
}
24142414
if (sock)
24152415
/* It's already INCREF'ed */

0 commit comments

Comments
 (0)