diff options
author | thiagoftsm <thiagoftsm@gmail.com> | 2022-06-15 15:03:12 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-15 15:03:12 +0000 |
commit | badcabc70ff006213a47db856430caeecfbae8a0 (patch) | |
tree | b4a3d138adee535458745bc35cc5a35e93d5184e /streaming/receiver.c | |
parent | 7f86425d20986feb2d210f87f7e5f2f52a9e802d (diff) |
Add missing control to streaming (#13112)
fix_tls_stream: Add call to SSL_get_error to avoid an infinite loop
Diffstat (limited to 'streaming/receiver.c')
-rw-r--r-- | streaming/receiver.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/streaming/receiver.c b/streaming/receiver.c index f29b16c432..3e8639151f 100644 --- a/streaming/receiver.c +++ b/streaming/receiver.c @@ -217,9 +217,19 @@ static int read_stream(struct receiver_state *r, FILE *fp, char* buffer, size_t // we need to receive data with LF to parse compression header size_t ofs = 0; int res = 0; + errno = 0; while (ofs < size) { do { res = SSL_read(r->ssl.conn, buffer + ofs, 1); + // When either SSL_ERROR_SYSCALL (OpenSSL < 3.0) or SSL_ERROR_SSL(OpenSSL > 3.0) happens, + // the connection was lost https://www.openssl.org/docs/man3.0/man3/SSL_get_error.html, + // without the test we will have an infinite loop https://github.com/netdata/netdata/issues/13092 + int local_ssl_err = SSL_get_error(r->ssl.conn, res); + if (local_ssl_err == SSL_ERROR_SYSCALL || local_ssl_err == SSL_ERROR_SSL) { + error("The SSL connection has error SSL_ERROR_SYSCALL(%d) and system is registering errno = %d", + local_ssl_err, errno); + return 1; + } } while (res == 0); if (res < 0) |