diff options
author | Pierre Ossman <ossman@cendio.se> | 2021-06-10 16:34:15 +0200 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2021-06-11 09:42:44 +0200 |
commit | 9c407d2a0bc11697ae8413a8e6bea21813fd6072 (patch) | |
tree | 570cb1cb4020c4935fa3f519d30f5da34e4cfe01 /common/rdr/TLSOutStream.cxx | |
parent | d1ad6b5c250d0bc4c43b4d9983badf8ce01b5747 (diff) | |
download | tigervnc-9c407d2a0bc11697ae8413a8e6bea21813fd6072.tar.gz tigervnc-9c407d2a0bc11697ae8413a8e6bea21813fd6072.zip |
Propagate exceptions from GnuTLS push/pull functions
Gives us a more meaningful error rather than just "Error in push/pull
function".
Diffstat (limited to 'common/rdr/TLSOutStream.cxx')
-rw-r--r-- | common/rdr/TLSOutStream.cxx | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/common/rdr/TLSOutStream.cxx b/common/rdr/TLSOutStream.cxx index 0fa14b39..dc6b55aa 100644 --- a/common/rdr/TLSOutStream.cxx +++ b/common/rdr/TLSOutStream.cxx @@ -42,16 +42,21 @@ ssize_t TLSOutStream::push(gnutls_transport_ptr_t str, const void* data, TLSOutStream* self= (TLSOutStream*) str; OutStream *out = self->out; + delete self->saved_exception; + self->saved_exception = NULL; + try { out->writeBytes(data, size); out->flush(); } catch (SystemException &e) { vlog.error("Failure sending TLS data: %s", e.str()); gnutls_transport_set_errno(self->session, e.err); + self->saved_exception = new SystemException(e); return -1; } catch (Exception& e) { vlog.error("Failure sending TLS data: %s", e.str()); gnutls_transport_set_errno(self->session, EINVAL); + self->saved_exception = new Exception(e); return -1; } @@ -59,7 +64,8 @@ ssize_t TLSOutStream::push(gnutls_transport_ptr_t str, const void* data, } TLSOutStream::TLSOutStream(OutStream* _out, gnutls_session_t _session) - : session(_session), out(_out), bufSize(DEFAULT_BUF_SIZE), offset(0) + : session(_session), out(_out), bufSize(DEFAULT_BUF_SIZE), offset(0), + saved_exception(NULL) { gnutls_transport_ptr_t recv, send; @@ -82,6 +88,7 @@ TLSOutStream::~TLSOutStream() gnutls_transport_set_push_function(session, NULL); delete [] start; + delete saved_exception; } size_t TLSOutStream::length() @@ -134,6 +141,9 @@ size_t TLSOutStream::writeTLS(const U8* data, size_t length) if (n == GNUTLS_E_INTERRUPTED || n == GNUTLS_E_AGAIN) return 0; + if (n == GNUTLS_E_PUSH_ERROR) + throw *saved_exception; + if (n < 0) throw TLSException("writeTLS", n); |