]> source.dussan.org Git - tigervnc.git/commitdiff
VNCSConnectionST clipboard functions should check state before access.
authorMark Mielke <mark.mielke@gmail.com>
Mon, 20 Feb 2023 05:38:52 +0000 (00:38 -0500)
committerPierre Ossman <ossman@cendio.se>
Tue, 28 Feb 2023 15:07:39 +0000 (16:07 +0100)
Clipboard functions may run on connections that are not yet at
RFBSTATE_NORMAL. Due to recent hardening of the accessCheck() function,
it is important to validate that the state is RFBSTATE_NORMAL before
calling accessCheck().

Fixes #1599.

(cherry picked from commit 995f443ef74ae9e25b7be31c5a390df35159ef10)

common/rfb/VNCSConnectionST.cxx

index 9f58e7868e14fdbeaa204aafae439b50e05defcc..23024c5e90f5b4f152deba0546c9ad29ff374e20 100644 (file)
@@ -313,9 +313,9 @@ void VNCSConnectionST::setLEDStateOrClose(unsigned int state)
 void VNCSConnectionST::requestClipboardOrClose()
 {
   try {
+    if (state() != RFBSTATE_NORMAL) return;
     if (!accessCheck(AccessCutText)) return;
     if (!rfb::Server::acceptCutText) return;
-    if (state() != RFBSTATE_NORMAL) return;
     requestClipboard();
   } catch(rdr::Exception& e) {
     close(e.str());
@@ -325,9 +325,9 @@ void VNCSConnectionST::requestClipboardOrClose()
 void VNCSConnectionST::announceClipboardOrClose(bool available)
 {
   try {
+    if (state() != RFBSTATE_NORMAL) return;
     if (!accessCheck(AccessCutText)) return;
     if (!rfb::Server::sendCutText) return;
-    if (state() != RFBSTATE_NORMAL) return;
     announceClipboard(available);
   } catch(rdr::Exception& e) {
     close(e.str());
@@ -337,9 +337,9 @@ void VNCSConnectionST::announceClipboardOrClose(bool available)
 void VNCSConnectionST::sendClipboardDataOrClose(const char* data)
 {
   try {
+    if (state() != RFBSTATE_NORMAL) return;
     if (!accessCheck(AccessCutText)) return;
     if (!rfb::Server::sendCutText) return;
-    if (state() != RFBSTATE_NORMAL) return;
     sendClipboardData(data);
   } catch(rdr::Exception& e) {
     close(e.str());