Kaydet (Commit) b6e3e3ab authored tarafından Antoine Pitrou's avatar Antoine Pitrou

Merged revisions 81241 via svnmerge from

svn+ssh://pythondev@svn.python.org/python/trunk

........
  r81241 | antoine.pitrou | 2010-05-17 01:11:46 +0200 (lun., 17 mai 2010) | 4 lines

  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.
........
üst ec0a3886
...@@ -196,6 +196,7 @@ PySSL_SetError(PySSLObject *obj, int ret, char *filename, int lineno) ...@@ -196,6 +196,7 @@ PySSL_SetError(PySSLObject *obj, int ret, char *filename, int lineno)
errstr = "EOF occurred in violation of protocol"; errstr = "EOF occurred in violation of protocol";
} else if (ret == -1) { } else if (ret == -1) {
/* underlying BIO reported an I/O error */ /* underlying BIO reported an I/O error */
ERR_clear_error();
return obj->Socket->errorhandler(); return obj->Socket->errorhandler();
} else { /* possible? */ } else { /* possible? */
p = PY_SSL_ERROR_SYSCALL; p = PY_SSL_ERROR_SYSCALL;
...@@ -228,6 +229,7 @@ PySSL_SetError(PySSLObject *obj, int ret, char *filename, int lineno) ...@@ -228,6 +229,7 @@ PySSL_SetError(PySSLObject *obj, int ret, char *filename, int lineno)
errstr = ERR_error_string(ERR_peek_last_error(), NULL); errstr = ERR_error_string(ERR_peek_last_error(), NULL);
} }
PyOS_snprintf(buf, sizeof(buf), "_ssl.c:%d: %s", lineno, errstr); PyOS_snprintf(buf, sizeof(buf), "_ssl.c:%d: %s", lineno, errstr);
ERR_clear_error();
v = Py_BuildValue("(is)", p, buf); v = Py_BuildValue("(is)", p, buf);
if (v != NULL) { if (v != NULL) {
PyErr_SetObject(PySSLErrorObject, v); PyErr_SetObject(PySSLErrorObject, v);
...@@ -247,6 +249,7 @@ _setSSLError (char *errstr, int errcode, char *filename, int lineno) { ...@@ -247,6 +249,7 @@ _setSSLError (char *errstr, int errcode, char *filename, int lineno) {
errstr = ERR_error_string(errcode, NULL); errstr = ERR_error_string(errcode, NULL);
} }
PyOS_snprintf(buf, sizeof(buf), "_ssl.c:%d: %s", lineno, errstr); PyOS_snprintf(buf, sizeof(buf), "_ssl.c:%d: %s", lineno, errstr);
ERR_clear_error();
v = Py_BuildValue("(is)", errcode, buf); v = Py_BuildValue("(is)", errcode, buf);
if (v != NULL) { if (v != NULL) {
PyErr_SetObject(PySSLErrorObject, v); PyErr_SetObject(PySSLErrorObject, v);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment