Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
common.h: Use better message for early client EOF
When SSL sees a client hangup, SSL_get_error currently returns SSL_ERROR_SYSCALL. The page at [1] says in section BUGS, that errno would be 0 in this case: The SSL_ERROR_SYSCALL with errno value of 0 indicates unexpected EOF from the peer. To my experimentation, this is not true. errno is left unchanged instead. The page at [2] says, that ERR_get_error could be used to distinguish between EOF and some errno indicated failure: SSL_ERROR_SYSCALL Some I/O error occurred. The OpenSSL error queue may contain more information on the error. If the error queue is empty (i.e. ERR_get_error() returns 0), ret can be used to find out more about the error: If ret == 0, an EOF was observed that violates the protocol. If ret == -1, the underlying BIO reported an I/O error (for socket I/O on Unix systems, consult errno for details). But to my experimentation, this is not true either. In both cases, ERR_get_error doesn't have any further information and ret (from SSL_accept) is -1 in both cases. This might be fixed in OpenSLL 3.0 [3]: On an unexpected EOF, versions before OpenSSL 3.0 returned SSL_ERROR_SYSCALL, nothing was added to the error stack, and errno was 0. Since OpenSSL 3.0 the returned error is SSL_ERROR_SSL with a meaningful error on the error stack. Although it is ugly, we only have the option to set errno to zero before the operation. do this in ssl_read_with_timeout and ssl_accept_with_timeout. [1]: https://www.openssl.org/docs/man1.1.1/man3/SSL_get_error.html [2]: https://linux.die.net/man/3/ssl_get_error [3]: https://www.openssl.org/docs/manmaster/man3/SSL_get_error.html
- Loading branch information