]> source.dussan.org Git - tigervnc.git/commitdiff
[Bugfix] Properly report transport errors to GNUTLS.
authorAdam Tkac <atkac@redhat.com>
Wed, 25 Aug 2010 13:52:49 +0000 (13:52 +0000)
committerAdam Tkac <atkac@redhat.com>
Wed, 25 Aug 2010 13:52:49 +0000 (13:52 +0000)
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

common/rdr/TLSInStream.cxx
common/rdr/TLSOutStream.cxx

index f6bf334c347b10791da370887a5c313d16ee1dbb..faf548c806c05b5620d16902899c21be0b2d986a 100644 (file)
@@ -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;
 }
 
index 59edf1507a2a5e1984b0c00b4e836b373313b934..888b455b586ee96581009e0b582825b73f067b40 100644 (file)
@@ -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;
 }