diff options
author | Azat Khuzhin <azat@libevent.org> | 2023-05-14 16:53:13 +0200 |
---|---|---|
committer | Azat Khuzhin <azat@libevent.org> | 2023-05-14 16:53:13 +0200 |
commit | 7652cf4068f77905a56b9165455ec7e90917ec31 (patch) | |
tree | d8069f294310ef5c1dee9b318edafae57ae53d47 /bufferevent_mbedtls.c | |
parent | 6375dcb46db4bb05c9c19c980f3ed6d0ff9b1065 (diff) | |
download | libevent-7652cf4068f77905a56b9165455ec7e90917ec31.tar.gz |
ssl: do not triger EOF if some data had been successfully read
Previously in case when evbuffer_reserve_space() returns > 1, but
it was able to read only 1 IO vector, it will try to read the next one,
got 0 (EOF for mbedTLS or SSL_ERROR_ZERO_RETURN for OpenSSL) and will
trigger EOF, while instead, it should trigger EV_READ w/o EOF and only
after EOF.
Diffstat (limited to 'bufferevent_mbedtls.c')
-rw-r--r-- | bufferevent_mbedtls.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/bufferevent_mbedtls.c b/bufferevent_mbedtls.c index b0e960fa..765d00be 100644 --- a/bufferevent_mbedtls.c +++ b/bufferevent_mbedtls.c @@ -136,6 +136,11 @@ mbedtls_is_want_write(int err) { return err == MBEDTLS_ERR_SSL_WANT_WRITE; } +static int mbedtls_err_is_ok(int err) +{ + /* What mbedtls_ssl_read() returns when the we can proceed existing data */ + return err == 0; +} static evutil_socket_t be_mbedtls_get_fd(void *ssl) @@ -324,6 +329,7 @@ static struct le_ssl_ops le_mbedtls_ops = { mbedtls_handshake_is_ok, mbedtls_is_want_read, mbedtls_is_want_write, + mbedtls_err_is_ok, be_mbedtls_get_fd, be_mbedtls_bio_set_fd, (void (*)(struct bufferevent_ssl *))mbedtls_set_ssl_noops, |