Signed-off-by: Martin Koegler <mkoeg...@auto.tuwien.ac.at>
---
 common/rdr/TLSInStream.cxx  |   27 ++++++++++++++++-----------
 common/rdr/TLSOutStream.cxx |   14 ++++++++++----
 2 files changed, 26 insertions(+), 15 deletions(-)

diff --git a/common/rdr/TLSInStream.cxx b/common/rdr/TLSInStream.cxx
index f6bf334..7a9859e 100644
--- a/common/rdr/TLSInStream.cxx
+++ b/common/rdr/TLSInStream.cxx
@@ -35,19 +35,24 @@ enum { DEFAULT_BUF_SIZE = 16384 };
 ssize_t rdr::gnutls_InStream_pull(gnutls_transport_ptr str, void* data,
                                  size_t size)
 {
-  InStream* in= (InStream*) str;
-
-  if (!in->check(1, 1, false)) {
-    errno=EAGAIN;
+  try {
+    InStream* in= (InStream*) str;
+  
+    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);
+  
+    return 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;
 }
 
 TLSInStream::TLSInStream(InStream* _in, gnutls_session _session)
diff --git a/common/rdr/TLSOutStream.cxx b/common/rdr/TLSOutStream.cxx
index 59edf15..03997d4 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;
@@ -34,10 +35,15 @@ enum { DEFAULT_BUF_SIZE = 16384 };
 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();
-  return size;
+  try {
+    OutStream* out = (OutStream*) str;
+    out->writeBytes(data, size);
+    out->flush();
+    return size;
+  } catch (Exception& e) {
+    gnutls_transport_set_global_errno (EINVAL);
+    return -1;
+  }
 }
 
 TLSOutStream::TLSOutStream(OutStream* _out, gnutls_session _session)
-- 
1.5.6.5


------------------------------------------------------------------------------
Sell apps to millions through the Intel(R) Atom(Tm) Developer Program
Be part of this innovative community and reach millions of netbook users 
worldwide. Take advantage of special opportunities to increase revenue and 
speed time-to-market. Join now, and jumpstart your future.
http://p.sf.net/sfu/intel-atom-d2d
_______________________________________________
Tigervnc-devel mailing list
Tigervnc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tigervnc-devel

Reply via email to