mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
Clear the OpenSSL error queue each time an error is signalled.
When the error queue is not emptied, strange things can happen on the next SSL call, depending on the OpenSSL version.
This commit is contained in:
parent
308c2af9a4
commit
508a237c97
1 changed files with 3 additions and 0 deletions
|
@ -196,6 +196,7 @@ PySSL_SetError(PySSLObject *obj, int ret, char *filename, int lineno)
|
|||
errstr = "EOF occurred in violation of protocol";
|
||||
} else if (ret == -1) {
|
||||
/* underlying BIO reported an I/O error */
|
||||
ERR_clear_error();
|
||||
return obj->Socket->errorhandler();
|
||||
} else { /* possible? */
|
||||
p = PY_SSL_ERROR_SYSCALL;
|
||||
|
@ -228,6 +229,7 @@ PySSL_SetError(PySSLObject *obj, int ret, char *filename, int lineno)
|
|||
errstr = ERR_error_string(ERR_peek_last_error(), NULL);
|
||||
}
|
||||
PyOS_snprintf(buf, sizeof(buf), "_ssl.c:%d: %s", lineno, errstr);
|
||||
ERR_clear_error();
|
||||
v = Py_BuildValue("(is)", p, buf);
|
||||
if (v != NULL) {
|
||||
PyErr_SetObject(PySSLErrorObject, v);
|
||||
|
@ -247,6 +249,7 @@ _setSSLError (char *errstr, int errcode, char *filename, int lineno) {
|
|||
errstr = ERR_error_string(errcode, NULL);
|
||||
}
|
||||
PyOS_snprintf(buf, sizeof(buf), "_ssl.c:%d: %s", lineno, errstr);
|
||||
ERR_clear_error();
|
||||
v = Py_BuildValue("(is)", errcode, buf);
|
||||
if (v != NULL) {
|
||||
PyErr_SetObject(PySSLErrorObject, v);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue