gh-115627: Fix PySSL_SetError handling SSL_ERROR_SYSCALL (GH-115628)

Python 3.10 changed from using SSL_write() and SSL_read() to SSL_write_ex() and
SSL_read_ex(), but did not update handling of the return value.

Change error handling so that the return value is not examined.
OSError (not EOF) is now returned when retval is 0.

According to *recent* man pages of all functions for which we call
PySSL_SetError, (in OpenSSL 3.0 and 1.1.1), their return value should
be used to determine whether an error happened (i.e. if PySSL_SetError
should be called), but not what kind of error happened (so,
PySSL_SetError shouldn't need retval). To get the error,
we need to use SSL_get_error.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
This commit is contained in:
yevgeny hong 2024-03-26 16:45:43 +09:00 committed by GitHub
parent d52bdfb19f
commit ea9a296fce
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 35 additions and 43 deletions

View file

@ -0,0 +1,2 @@
Fix the :mod:`ssl` module error handling of connection terminate by peer.
It now throws an OSError with the appropriate error code instead of an EOFError.