aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorAdam Tkac <atkac@redhat.com>2010-08-25 13:52:49 +0000
committerAdam Tkac <atkac@redhat.com>2010-08-25 13:52:49 +0000
commitfab093c637cb0d8837802869321cd0abed7f156c (patch)
treebb5165469cfd6160cb611ab36db6395e399cdd33 /common
parent8109fc96635b24cc9f185003b1c0e2c6076b72fd (diff)
downloadtigervnc-fab093c637cb0d8837802869321cd0abed7f156c.tar.gz
tigervnc-fab093c637cb0d8837802869321cd0abed7f156c.zip
[Bugfix] Properly report transport errors to GNUTLS.
Signed-off-by: Martin Koegler <mkoegler@auto.tuwien.ac.at> git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4125 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'common')
-rw-r--r--common/rdr/TLSInStream.cxx20
-rw-r--r--common/rdr/TLSOutStream.cxx12
2 files changed, 23 insertions, 9 deletions
diff --git a/common/rdr/TLSInStream.cxx b/common/rdr/TLSInStream.cxx
index f6bf334c..faf548c8 100644
--- a/common/rdr/TLSInStream.cxx
+++ b/common/rdr/TLSInStream.cxx
@@ -37,16 +37,22 @@ ssize_t rdr::gnutls_InStream_pull(gnutls_transport_ptr str, void* data,
{
InStream* in= (InStream*) str;
- if (!in->check(1, 1, false)) {
- errno=EAGAIN;
+ try {
+ if (!in->check(1, 1, false)) {
+ gnutls_transport_set_global_errno(EAGAIN);
+ return -1;
+ }
+
+ if (in->getend() - in->getptr() < size)
+ size = in->getend() - in->getptr();
+
+ in->readBytes(data, size);
+
+ } catch (Exception& e) {
+ gnutls_transport_set_global_errno(EINVAL);
return -1;
}
- if (in->getend() - in->getptr() < size)
- size = in->getend() - in->getptr();
-
- in->readBytes(data, size);
-
return size;
}
diff --git a/common/rdr/TLSOutStream.cxx b/common/rdr/TLSOutStream.cxx
index 59edf150..888b455b 100644
--- a/common/rdr/TLSOutStream.cxx
+++ b/common/rdr/TLSOutStream.cxx
@@ -25,6 +25,7 @@
#include <rdr/Exception.h>
#include <rdr/TLSException.h>
#include <rdr/TLSOutStream.h>
+#include <errno.h>
#ifdef HAVE_GNUTLS
using namespace rdr;
@@ -35,8 +36,15 @@ ssize_t rdr::gnutls_OutStream_push(gnutls_transport_ptr str, const void* data,
size_t size)
{
OutStream* out = (OutStream*) str;
- out->writeBytes(data, size);
- out->flush();
+
+ try {
+ out->writeBytes(data, size);
+ out->flush();
+ } catch (Exception& e) {
+ gnutls_transport_set_global_errno(EINVAL);
+ return -1;
+ }
+
return size;
}