File U_Handle-pending-data-in-TLS-buffers.patch of Package tigervnc.25014

From ec3899ecd1c49548b08dd38e1e7a93b4602328a8 Mon Sep 17 00:00:00 2001
From: Pierre Ossman <ossman@cendio.se>
Date: Mon, 9 Dec 2019 16:57:04 +0100
Subject: [PATCH 1/2] Handle pending data in TLS buffers
References: bsc#1199477
Upstream: Merged

There might be more bytes left in the current TLS record, even if
there is nothing on the underlying stream. Make sure we properly
return this when we aren't being requested to block.
---
 common/rdr/TLSInStream.cxx | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/common/rdr/TLSInStream.cxx b/common/rdr/TLSInStream.cxx
index 77b16729..8cd07b6c 100644
--- a/common/rdr/TLSInStream.cxx
+++ b/common/rdr/TLSInStream.cxx
@@ -111,9 +111,11 @@ size_t TLSInStream::readTLS(U8* buf, siz
 {
   int n;
 
-  n = in->check(1, 1, wait);
-  if (n == 0)
-    return 0;
+  if (gnutls_record_check_pending(session) == 0) {
+    n = in->check(1, 1, wait);
+    if (n == 0)
+      return 0;
+  }
 
   n = gnutls_record_recv(session, (void *) buf, len);
   if (n == GNUTLS_E_INTERRUPTED || n == GNUTLS_E_AGAIN)
-- 
2.36.1


From 10c40dbc8639acf97b246cfebc2b4bf8c55d564d Mon Sep 17 00:00:00 2001
From: Pierre Ossman <ossman@cendio.se>
Date: Mon, 9 Dec 2019 16:58:07 +0100
Subject: [PATCH 2/2] Check the correct stream if there is more data pending

The input stream might no longer be the raw socket, so we need to
query what's currently active. That wrapping stream might have its
own buffering and may have more data even if the socket is drained.
---
 vncviewer/CConn.cxx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/vncviewer/CConn.cxx b/vncviewer/CConn.cxx
index 6ba3276b..eba5dd34 100644
--- a/vncviewer/CConn.cxx
+++ b/vncviewer/CConn.cxx
@@ -266,7 +266,7 @@ void CConn::socketEvent(FL_SOCKET fd, void *data)
        // Also check if we need to stop reading and terminate
        if (should_exit())
          break;
-    } while (cc->sock->inStream().checkNoWait(1));
+    } while (cc->getInStream()->checkNoWait(1));
   } catch (rdr::EndOfStream& e) {
     vlog.info("%s", e.str());
     exit_vncviewer();
-- 
2.36.1

openSUSE Build Service is sponsored by