]> source.dussan.org Git - tigervnc.git/commitdiff
Throw exception instead on bad access check
authorPierre Ossman <ossman@cendio.se>
Tue, 28 Feb 2023 15:00:15 +0000 (16:00 +0100)
committerPierre Ossman <ossman@cendio.se>
Tue, 28 Feb 2023 15:00:15 +0000 (16:00 +0100)
An assert will kill the entire server, which is overly harsh when there
is a problem with a single connection. Instead, throw an exception which
will just disconnect that specific client.

common/rfb/SConnection.cxx

index 8e0bff8cc2c59db8dacbb7982cb8c379846e67b1..0bb8e4a926ca887e11f0ae1587bbcd1ca8625936 100644 (file)
@@ -23,7 +23,6 @@
 
 #include <stdio.h>
 #include <string.h>
-#include <assert.h>
 #include <rfb/Exception.h>
 #include <rfb/Security.h>
 #include <rfb/clipboardTypes.h>
@@ -347,7 +346,8 @@ void SConnection::setAccessRights(AccessRights ar)
 
 bool SConnection::accessCheck(AccessRights ar) const
 {
-  assert(state_ >= RFBSTATE_QUERYING);
+  if (state_ < RFBSTATE_QUERYING)
+    throw Exception("SConnection::accessCheck: invalid state");
 
   return (accessRights & ar) == ar;
 }