bpo-34759: Fix error handling in ssl 'unwrap()' (GH-9468)

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 c6fd1c1c3a 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
This commit is contained in:
Nathaniel J. Smith 2018-09-21 21:44:12 -07:00 committed by Miss Islington (bot)
parent 026337a710
commit c0da582b22
2 changed files with 43 additions and 2 deletions

View file

@ -2583,9 +2583,9 @@ _ssl__SSLSocket_shutdown_impl(PySSLSocket *self)
break;
}
if (err.ssl < 0) {
if (ret < 0) {
Py_XDECREF(sock);
return PySSL_SetError(self, err.ssl, __FILE__, __LINE__);
return PySSL_SetError(self, ret, __FILE__, __LINE__);
}
if (sock)
/* It's already INCREF'ed */