From f4fdc13f37f7ae67b2ba110c24366f84e1e70734 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Wed, 20 May 2020 20:03:11 +0200 Subject: [PATCH] Log I/O errors from TLS streams --- common/rdr/TLSInStream.cxx | 7 ++++++- common/rdr/TLSOutStream.cxx | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/common/rdr/TLSInStream.cxx b/common/rdr/TLSInStream.cxx index 70303db0..ba20e752 100644 --- a/common/rdr/TLSInStream.cxx +++ b/common/rdr/TLSInStream.cxx @@ -25,11 +25,14 @@ #include #include #include +#include #include #ifdef HAVE_GNUTLS using namespace rdr; +static rfb::LogWriter vlog("TLSInStream"); + ssize_t TLSInStream::pull(gnutls_transport_ptr_t str, void* data, size_t size) { TLSInStream* self= (TLSInStream*) str; @@ -45,8 +48,10 @@ ssize_t TLSInStream::pull(gnutls_transport_ptr_t str, void* data, size_t size) size = in->avail(); in->readBytes(data, size); - + } catch (EndOfStream&) { + return 0; } catch (Exception& e) { + vlog.error("Failure reading TLS data: %s", e.str()); gnutls_transport_set_errno(self->session, EINVAL); return -1; } diff --git a/common/rdr/TLSOutStream.cxx b/common/rdr/TLSOutStream.cxx index 7d59a9c7..a883fe89 100644 --- a/common/rdr/TLSOutStream.cxx +++ b/common/rdr/TLSOutStream.cxx @@ -25,11 +25,14 @@ #include #include #include +#include #include #ifdef HAVE_GNUTLS using namespace rdr; +static rfb::LogWriter vlog("TLSOutStream"); + enum { DEFAULT_BUF_SIZE = 16384 }; ssize_t TLSOutStream::push(gnutls_transport_ptr_t str, const void* data, @@ -42,6 +45,7 @@ ssize_t TLSOutStream::push(gnutls_transport_ptr_t str, const void* data, out->writeBytes(data, size); out->flush(); } catch (Exception& e) { + vlog.error("Failure sending TLS data: %s", e.str()); gnutls_transport_set_errno(self->session, EINVAL); return -1; } -- 2.39.5