aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2024-09-02 20:41:47 +0200
committerPierre Ossman <ossman@cendio.se>2024-09-02 20:41:47 +0200
commitda1adb5073dad2ae9cd968dc6f213c9f027c46ce (patch)
treefb6ce46052179f2ab5e139fa1c65363a00fb14d1
parent2e3347768d3d19852e2c575d1b9425e23d6efa87 (diff)
downloadtigervnc-da1adb5073dad2ae9cd968dc6f213c9f027c46ce.tar.gz
tigervnc-da1adb5073dad2ae9cd968dc6f213c9f027c46ce.zip
Remove ConnFailedException
There were more unclear usage of this exception class, and since nothing catches it it is very unclear what the purpose is. Go ahead and just remove it. Follow-up to bcaaea7.
-rw-r--r--common/rfb/Exception.h4
-rw-r--r--common/rfb/SConnection.cxx18
-rw-r--r--common/rfb/SConnection.h8
-rw-r--r--common/rfb/SSecurityRSAAES.cxx18
4 files changed, 22 insertions, 26 deletions
diff --git a/common/rfb/Exception.h b/common/rfb/Exception.h
index 4520bc8c..773c65fa 100644
--- a/common/rfb/Exception.h
+++ b/common/rfb/Exception.h
@@ -30,9 +30,5 @@ namespace rfb {
AuthCancelledException()
: Exception("Authentication cancelled") {}
};
- struct ConnFailedException : public Exception {
- ConnFailedException(const char* reason)
- : Exception("%s", reason) {}
- };
}
#endif
diff --git a/common/rfb/SConnection.cxx b/common/rfb/SConnection.cxx
index 08cef044..905f88a4 100644
--- a/common/rfb/SConnection.cxx
+++ b/common/rfb/SConnection.cxx
@@ -133,9 +133,9 @@ bool SConnection::processVersionMsg()
if (client.majorVersion != 3) {
// unknown protocol version
- throwConnFailedException("Client needs protocol version %d.%d, server has %d.%d",
- client.majorVersion, client.minorVersion,
- defaultMajorVersion, defaultMinorVersion);
+ failConnection("Client needs protocol version %d.%d, server has %d.%d",
+ client.majorVersion, client.minorVersion,
+ defaultMajorVersion, defaultMinorVersion);
}
if (client.minorVersion != 3 && client.minorVersion != 7 && client.minorVersion != 8) {
@@ -165,8 +165,8 @@ bool SConnection::processVersionMsg()
if (*i == secTypeNone || *i == secTypeVncAuth) break;
}
if (i == secTypes.end()) {
- throwConnFailedException("No supported security type for %d.%d client",
- client.majorVersion, client.minorVersion);
+ failConnection("No supported security type for %d.%d client",
+ client.majorVersion, client.minorVersion);
}
os->writeU32(*i);
@@ -179,7 +179,7 @@ bool SConnection::processVersionMsg()
// list supported security types for >=3.7 clients
if (secTypes.empty())
- throwConnFailedException("No supported security types");
+ failConnection("No supported security types");
os->writeU8(secTypes.size());
for (i=secTypes.begin(); i!=secTypes.end(); i++)
@@ -222,7 +222,7 @@ void SConnection::processSecurityType(int secType)
state_ = RFBSTATE_SECURITY;
ssecurity = security.GetSSecurity(this, secType);
} catch (rdr::Exception& e) {
- throwConnFailedException("%s", e.str());
+ failConnection("%s", e.str());
}
}
@@ -299,7 +299,7 @@ void SConnection::handleAuthFailureTimeout(Timer* /*t*/)
close(authFailureMsg.c_str());
}
-void SConnection::throwConnFailedException(const char* format, ...)
+void SConnection::failConnection(const char* format, ...)
{
va_list ap;
char str[256];
@@ -325,7 +325,7 @@ void SConnection::throwConnFailedException(const char* format, ...)
}
state_ = RFBSTATE_INVALID;
- throw ConnFailedException(str);
+ throw Exception("%s", str);
}
void SConnection::setAccessRights(AccessRights ar)
diff --git a/common/rfb/SConnection.h b/common/rfb/SConnection.h
index 46b427ed..0a11f67b 100644
--- a/common/rfb/SConnection.h
+++ b/common/rfb/SConnection.h
@@ -216,10 +216,10 @@ namespace rfb {
int32_t getPreferredEncoding() { return preferredEncoding; }
protected:
- // throwConnFailedException() prints a message to the log, sends a conn
- // failed message to the client (if possible) and throws a
- // ConnFailedException.
- void throwConnFailedException(const char* format, ...)
+ // failConnection() prints a message to the log, sends a connection
+ // failed message to the client (if possible) and throws an
+ // Exception.
+ void failConnection(const char* format, ...)
__attribute__((__format__ (__printf__, 2, 3)));
void setState(stateEnum s) { state_ = s; }
diff --git a/common/rfb/SSecurityRSAAES.cxx b/common/rfb/SSecurityRSAAES.cxx
index 37860a10..5b3a04d2 100644
--- a/common/rfb/SSecurityRSAAES.cxx
+++ b/common/rfb/SSecurityRSAAES.cxx
@@ -295,9 +295,9 @@ bool SSecurityRSAAES::readPublicKey()
is->setRestorePoint();
clientKeyLength = is->readU32();
if (clientKeyLength < MinKeyLength)
- throw ConnFailedException("client key is too short");
+ throw Exception("client key is too short");
if (clientKeyLength > MaxKeyLength)
- throw ConnFailedException("client key is too long");
+ throw Exception("client key is too long");
size_t size = (clientKeyLength + 7) / 8;
if (!is->hasDataOrRestore(size * 2))
return false;
@@ -310,7 +310,7 @@ bool SSecurityRSAAES::readPublicKey()
nettle_mpz_set_str_256_u(clientKey.n, size, clientKeyN);
nettle_mpz_set_str_256_u(clientKey.e, size, clientKeyE);
if (!rsa_public_key_prepare(&clientKey))
- throw ConnFailedException("client key is invalid");
+ throw Exception("client key is invalid");
return true;
}
@@ -318,7 +318,7 @@ static void random_func(void* ctx, size_t length, uint8_t* dst)
{
rdr::RandomStream* rs = (rdr::RandomStream*)ctx;
if (!rs->hasData(length))
- throw ConnFailedException("failed to encrypt random");
+ throw Exception("failed to encrypt random");
rs->readBytes(dst, length);
}
@@ -326,7 +326,7 @@ void SSecurityRSAAES::writeRandom()
{
rdr::OutStream* os = sc->getOutStream();
if (!rs.hasData(keySize / 8))
- throw ConnFailedException("failed to generate random");
+ throw Exception("failed to generate random");
rs.readBytes(serverRandom, keySize / 8);
mpz_t x;
mpz_init(x);
@@ -340,7 +340,7 @@ void SSecurityRSAAES::writeRandom()
}
if (!res) {
mpz_clear(x);
- throw ConnFailedException("failed to encrypt random");
+ throw Exception("failed to encrypt random");
}
uint8_t* buffer = new uint8_t[clientKey.size];
nettle_mpz_get_str_256(clientKey.size, buffer, x);
@@ -359,7 +359,7 @@ bool SSecurityRSAAES::readRandom()
is->setRestorePoint();
size_t size = is->readU16();
if (size != serverKey.size)
- throw ConnFailedException("server key length doesn't match");
+ throw Exception("server key length doesn't match");
if (!is->hasDataOrRestore(size))
return false;
is->clearRestorePoint();
@@ -372,7 +372,7 @@ bool SSecurityRSAAES::readRandom()
if (!rsa_decrypt(&serverKey, &randomSize, clientRandom, x) ||
randomSize != (size_t)keySize / 8) {
mpz_clear(x);
- throw ConnFailedException("failed to decrypt client random");
+ throw Exception("failed to decrypt client random");
}
mpz_clear(x);
return true;
@@ -501,7 +501,7 @@ bool SSecurityRSAAES::readHash()
sha256_digest(&ctx, hashSize, realHash);
}
if (memcmp(hash, realHash, hashSize) != 0)
- throw ConnFailedException("hash doesn't match");
+ throw Exception("hash doesn't match");
return true;
}