aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/network/Socket.cxx2
-rw-r--r--common/network/TcpSocket.cxx18
-rw-r--r--common/network/UnixSocket.cxx3
-rw-r--r--common/rdr/BufferedInStream.cxx11
-rw-r--r--common/rdr/BufferedOutStream.cxx10
-rw-r--r--common/rdr/HexInStream.cxx3
-rw-r--r--common/rdr/InStream.h14
-rw-r--r--common/rdr/MemOutStream.h3
-rw-r--r--common/rdr/OutStream.h5
-rw-r--r--common/rdr/ZlibInStream.cxx9
-rw-r--r--common/rdr/ZlibOutStream.cxx9
-rw-r--r--common/rfb/CConnection.cxx6
-rw-r--r--common/rfb/CMsgWriter.cxx23
-rw-r--r--common/rfb/CSecurityDH.cxx8
-rw-r--r--common/rfb/CSecurityMSLogonII.cxx9
-rw-r--r--common/rfb/CSecurityRSAAES.cxx12
-rw-r--r--common/rfb/CSecurityTLS.cxx8
-rw-r--r--common/rfb/ClientParams.cxx9
-rw-r--r--common/rfb/Configuration.cxx7
-rw-r--r--common/rfb/Cursor.cxx5
-rw-r--r--common/rfb/DecodeManager.cxx4
-rw-r--r--common/rfb/EncodeManager.cxx3
-rw-r--r--common/rfb/H264Decoder.cxx5
-rw-r--r--common/rfb/H264DecoderContext.cxx5
-rw-r--r--common/rfb/H264LibavDecoderContext.cxx3
-rw-r--r--common/rfb/Hostname.h12
-rw-r--r--common/rfb/JpegCompressor.cxx9
-rw-r--r--common/rfb/JpegDecompressor.cxx4
-rw-r--r--common/rfb/PixelBuffer.cxx89
-rw-r--r--common/rfb/PixelFormat.cxx2
-rw-r--r--common/rfb/SConnection.cxx14
-rw-r--r--common/rfb/SMsgWriter.cxx97
-rw-r--r--common/rfb/SSecurityPlain.cxx2
-rw-r--r--common/rfb/SSecurityRSAAES.cxx18
-rw-r--r--common/rfb/SSecurityVncAuth.cxx4
-rw-r--r--common/rfb/SecurityClient.cxx3
-rw-r--r--common/rfb/SecurityServer.cxx3
-rw-r--r--common/rfb/ServerParams.cxx9
-rw-r--r--common/rfb/VNCServerST.cxx19
-rw-r--r--common/rfb/obfuscate.cxx5
40 files changed, 246 insertions, 238 deletions
diff --git a/common/network/Socket.cxx b/common/network/Socket.cxx
index 8bb96763..03844acd 100644
--- a/common/network/Socket.cxx
+++ b/common/network/Socket.cxx
@@ -39,6 +39,8 @@
#include <fcntl.h>
#include <errno.h>
+#include <rdr/Exception.h>
+
#include <network/Socket.h>
using namespace network;
diff --git a/common/network/TcpSocket.cxx b/common/network/TcpSocket.cxx
index 38cb6eb3..455df749 100644
--- a/common/network/TcpSocket.cxx
+++ b/common/network/TcpSocket.cxx
@@ -38,7 +38,10 @@
#include <stdlib.h>
#include <unistd.h>
+#include <rdr/Exception.h>
+
#include <network/TcpSocket.h>
+
#include <rfb/LogWriter.h>
#include <rfb/Configuration.h>
#include <rfb/util.h>
@@ -200,7 +203,7 @@ TcpSocket::TcpSocket(const char *host, int port)
if (sock == -1) {
if (err == 0)
- throw Exception("No useful address for host");
+ throw std::runtime_error("No useful address for host");
else
throw SocketException("unable to connect to socket", err);
}
@@ -607,7 +610,7 @@ TcpFilter::Pattern TcpFilter::parsePattern(const char* p) {
parts = rfb::split(&p[1], '/');
if (parts.size() > 2)
- throw Exception("invalid filter specified");
+ throw std::invalid_argument("invalid filter specified");
if (parts[0].empty()) {
// Match any address
@@ -641,8 +644,8 @@ TcpFilter::Pattern TcpFilter::parsePattern(const char* p) {
if (parts.size() > 1) {
if (family == AF_INET &&
(parts[1].find('.') != std::string::npos)) {
- throw Exception("mask no longer supported for filter, "
- "use prefix instead");
+ throw std::invalid_argument("mask no longer supported for "
+ "filter, use prefix instead");
}
pattern.prefixlen = (unsigned int) atoi(parts[1].c_str());
@@ -655,7 +658,7 @@ TcpFilter::Pattern TcpFilter::parsePattern(const char* p) {
pattern.prefixlen = 128;
break;
default:
- throw Exception("unknown address family");
+ throw std::runtime_error("unknown address family");
}
}
}
@@ -663,8 +666,9 @@ TcpFilter::Pattern TcpFilter::parsePattern(const char* p) {
family = pattern.address.u.sa.sa_family;
if (pattern.prefixlen > (family == AF_INET ? 32: 128))
- throw Exception(rfb::format("invalid prefix length for filter address: %u",
- pattern.prefixlen));
+ throw std::invalid_argument(rfb::format("invalid prefix length for "
+ "filter address: %u",
+ pattern.prefixlen));
// Compute mask from address and prefix length
memset (&pattern.mask, 0, sizeof (pattern.mask));
diff --git a/common/network/UnixSocket.cxx b/common/network/UnixSocket.cxx
index 3a422b6c..4b82b4b7 100644
--- a/common/network/UnixSocket.cxx
+++ b/common/network/UnixSocket.cxx
@@ -29,7 +29,10 @@
#include <stdlib.h>
#include <stddef.h>
+#include <rdr/Exception.h>
+
#include <network/UnixSocket.h>
+
#include <rfb/LogWriter.h>
using namespace network;
diff --git a/common/rdr/BufferedInStream.cxx b/common/rdr/BufferedInStream.cxx
index 204202ec..bf94a950 100644
--- a/common/rdr/BufferedInStream.cxx
+++ b/common/rdr/BufferedInStream.cxx
@@ -24,7 +24,6 @@
#include <assert.h>
#include <rdr/BufferedInStream.h>
-#include <rdr/Exception.h>
#include <rfb/util.h>
@@ -65,10 +64,12 @@ void BufferedInStream::ensureSpace(size_t needed)
uint8_t* newBuffer;
if (needed > MAX_BUF_SIZE)
- throw Exception(rfb::format("BufferedInStream overrun: requested "
- "size of %lu bytes exceeds maximum "
- "of %lu bytes", (long unsigned)needed,
- (long unsigned)MAX_BUF_SIZE));
+ throw std::out_of_range(rfb::format("BufferedInStream overrun: "
+ "requested size of %lu bytes "
+ "exceeds maximum of %lu "
+ "bytes",
+ (long unsigned)needed,
+ (long unsigned)MAX_BUF_SIZE));
newSize = DEFAULT_BUF_SIZE;
while (newSize < needed)
diff --git a/common/rdr/BufferedOutStream.cxx b/common/rdr/BufferedOutStream.cxx
index f5062bf2..efb71dd7 100644
--- a/common/rdr/BufferedOutStream.cxx
+++ b/common/rdr/BufferedOutStream.cxx
@@ -23,7 +23,6 @@
#endif
#include <rdr/BufferedOutStream.h>
-#include <rdr/Exception.h>
#include <rfb/util.h>
@@ -139,10 +138,11 @@ void BufferedOutStream::overrun(size_t needed)
// We'll need to allocate more buffer space...
if (totalNeeded > MAX_BUF_SIZE)
- throw Exception(rfb::format("BufferedOutStream overrun: requested "
- "size of %lu bytes exceeds maximum of "
- "%lu bytes", (long unsigned)totalNeeded,
- (long unsigned)MAX_BUF_SIZE));
+ throw std::out_of_range(rfb::format("BufferedOutStream overrun: "
+ "requested size of %lu bytes "
+ "exceeds maximum of %lu bytes",
+ (long unsigned)totalNeeded,
+ (long unsigned)MAX_BUF_SIZE));
newSize = DEFAULT_BUF_SIZE;
while (newSize < totalNeeded)
diff --git a/common/rdr/HexInStream.cxx b/common/rdr/HexInStream.cxx
index 11f98498..69c3e260 100644
--- a/common/rdr/HexInStream.cxx
+++ b/common/rdr/HexInStream.cxx
@@ -23,7 +23,6 @@
#include <algorithm>
#include <rdr/HexInStream.h>
-#include <rdr/Exception.h>
#include <rfb/util.h>
using namespace rdr;
@@ -46,7 +45,7 @@ bool HexInStream::fillBuffer() {
uint8_t* optr = (uint8_t*) end;
for (size_t i=0; i<length; i++) {
if (!rfb::hexToBin((const char*)&iptr[i*2], 2, &optr[i], 1))
- throw Exception("HexInStream: Invalid input data");
+ throw std::runtime_error("HexInStream: Invalid input data");
}
in_stream.setptr(length*2);
diff --git a/common/rdr/InStream.h b/common/rdr/InStream.h
index 939439e1..5623142c 100644
--- a/common/rdr/InStream.h
+++ b/common/rdr/InStream.h
@@ -28,7 +28,7 @@
#include <stdint.h>
#include <string.h> // for memcpy
-#include <rdr/Exception.h>
+#include <stdexcept>
// Check that callers are using InStream properly,
// useful when writing new protocol handling
@@ -101,21 +101,21 @@ namespace rdr {
inline void setRestorePoint() {
#ifdef RFB_INSTREAM_CHECK
if (restorePoint != nullptr)
- throw Exception("Nested use of input stream restore point");
+ throw std::logic_error("Nested use of input stream restore point");
#endif
restorePoint = ptr;
}
inline void clearRestorePoint() {
#ifdef RFB_INSTREAM_CHECK
if (restorePoint == nullptr)
- throw Exception("Incorrect clearing of input stream restore point");
+ throw std::logic_error("Incorrect clearing of input stream restore point");
#endif
restorePoint = nullptr;
}
inline void gotoRestorePoint() {
#ifdef RFB_INSTREAM_CHECK
if (restorePoint == nullptr)
- throw Exception("Incorrect activation of input stream restore point");
+ throw std::logic_error("Incorrect activation of input stream restore point");
#endif
ptr = restorePoint;
clearRestorePoint();
@@ -176,7 +176,7 @@ namespace rdr {
inline const uint8_t* getptr(size_t length) { check(length);
return ptr; }
inline void setptr(size_t length) { if (length > avail())
- throw Exception("Input stream overflow");
+ throw std::out_of_range("Input stream overflow");
skip(length); }
private:
@@ -189,11 +189,11 @@ namespace rdr {
inline void check(size_t bytes) {
#ifdef RFB_INSTREAM_CHECK
if (bytes > checkedBytes)
- throw Exception("Input stream used without underrun check");
+ throw std::logic_error("Input stream used without underrun check");
checkedBytes -= bytes;
#endif
if (bytes > (size_t)(end - ptr))
- throw Exception("InStream buffer underrun");
+ throw std::out_of_range("InStream buffer underrun");
}
// overrun() is implemented by a derived class to cope with buffer overrun.
diff --git a/common/rdr/MemOutStream.h b/common/rdr/MemOutStream.h
index 9bf2b810..bf05d92c 100644
--- a/common/rdr/MemOutStream.h
+++ b/common/rdr/MemOutStream.h
@@ -23,7 +23,6 @@
#ifndef __RDR_MEMOUTSTREAM_H__
#define __RDR_MEMOUTSTREAM_H__
-#include <rdr/Exception.h>
#include <rdr/OutStream.h>
namespace rdr {
@@ -61,7 +60,7 @@ namespace rdr {
len = (end - start) * 2;
if (len < (size_t)(end - start))
- throw Exception("Overflow in MemOutStream::overrun()");
+ throw std::out_of_range("Overflow in MemOutStream::overrun()");
uint8_t* newStart = new uint8_t[len];
memcpy(newStart, start, ptr - start);
diff --git a/common/rdr/OutStream.h b/common/rdr/OutStream.h
index 2921b232..b78ec4b0 100644
--- a/common/rdr/OutStream.h
+++ b/common/rdr/OutStream.h
@@ -27,7 +27,8 @@
#include <stdint.h>
#include <string.h> // for memcpy
-#include <rdr/Exception.h>
+#include <stdexcept>
+
#include <rdr/InStream.h>
namespace rdr {
@@ -129,7 +130,7 @@ namespace rdr {
inline uint8_t* getptr(size_t length) { check(length); return ptr; }
inline void setptr(size_t length) { if (length > avail())
- throw Exception("Output stream overflow");
+ throw std::out_of_range("Output stream overflow");
ptr += length; }
private:
diff --git a/common/rdr/ZlibInStream.cxx b/common/rdr/ZlibInStream.cxx
index a90d50f7..c9f8aeca 100644
--- a/common/rdr/ZlibInStream.cxx
+++ b/common/rdr/ZlibInStream.cxx
@@ -23,7 +23,6 @@
#include <assert.h>
#include <rdr/ZlibInStream.h>
-#include <rdr/Exception.h>
#include <zlib.h>
using namespace rdr;
@@ -50,7 +49,7 @@ void ZlibInStream::flushUnderlying()
{
while (bytesIn > 0) {
if (!hasData(1))
- throw Exception("ZlibInStream: failed to flush remaining stream data");
+ throw std::runtime_error("ZlibInStream: failed to flush remaining stream data");
skip(avail());
}
@@ -76,7 +75,7 @@ void ZlibInStream::init()
if (inflateInit(zs) != Z_OK) {
delete zs;
zs = nullptr;
- throw Exception("ZlibInStream: inflateInit failed");
+ throw std::runtime_error("ZlibInStream: inflateInit failed");
}
}
@@ -92,7 +91,7 @@ void ZlibInStream::deinit()
bool ZlibInStream::fillBuffer()
{
if (!underlying)
- throw Exception("ZlibInStream overrun: no underlying stream");
+ throw std::runtime_error("ZlibInStream overrun: no underlying stream");
zs->next_out = (uint8_t*)end;
zs->avail_out = availSpace();
@@ -107,7 +106,7 @@ bool ZlibInStream::fillBuffer()
int rc = inflate(zs, Z_SYNC_FLUSH);
if (rc < 0) {
- throw Exception("ZlibInStream: inflate failed");
+ throw std::runtime_error("ZlibInStream: inflate failed");
}
bytesIn -= length - zs->avail_in;
diff --git a/common/rdr/ZlibOutStream.cxx b/common/rdr/ZlibOutStream.cxx
index 1b59f54e..13788f8d 100644
--- a/common/rdr/ZlibOutStream.cxx
+++ b/common/rdr/ZlibOutStream.cxx
@@ -24,7 +24,6 @@
#include <stdio.h>
#include <rdr/ZlibOutStream.h>
-#include <rdr/Exception.h>
#include <rfb/LogWriter.h>
#include <zlib.h>
@@ -46,7 +45,7 @@ ZlibOutStream::ZlibOutStream(OutStream* os, int compressLevel)
zs->avail_in = 0;
if (deflateInit(zs, compressLevel) != Z_OK) {
delete zs;
- throw Exception("ZlibOutStream: deflateInit failed");
+ throw std::runtime_error("ZlibOutStream: deflateInit failed");
}
}
@@ -113,7 +112,7 @@ void ZlibOutStream::deflate(int flush)
int rc;
if (!underlying)
- throw Exception("ZlibOutStream: underlying OutStream has not been set");
+ throw std::runtime_error("ZlibOutStream: underlying OutStream has not been set");
if ((flush == Z_NO_FLUSH) && (zs->avail_in == 0))
return;
@@ -134,7 +133,7 @@ void ZlibOutStream::deflate(int flush)
if ((rc == Z_BUF_ERROR) && (flush != Z_NO_FLUSH))
break;
- throw Exception("ZlibOutStream: deflate failed");
+ throw std::runtime_error("ZlibOutStream: deflate failed");
}
#ifdef ZLIBOUT_DEBUG
@@ -168,7 +167,7 @@ void ZlibOutStream::checkCompressionLevel()
// explicit flush we did above. It should be safe to ignore though
// as the first flush should have left things in a stable state...
if (rc != Z_BUF_ERROR)
- throw Exception("ZlibOutStream: deflateParams failed");
+ throw std::runtime_error("ZlibOutStream: deflateParams failed");
}
compressionLevel = newLevel;
diff --git a/common/rfb/CConnection.cxx b/common/rfb/CConnection.cxx
index 3a34740f..244c8862 100644
--- a/common/rfb/CConnection.cxx
+++ b/common/rfb/CConnection.cxx
@@ -147,11 +147,11 @@ bool CConnection::processMsg()
case RFBSTATE_INITIALISATION: return processInitMsg(); break;
case RFBSTATE_NORMAL: return reader_->readMsg(); break;
case RFBSTATE_CLOSING:
- throw Exception("CConnection::processMsg: called while closing");
+ throw std::logic_error("CConnection::processMsg: called while closing");
case RFBSTATE_UNINITIALISED:
- throw Exception("CConnection::processMsg: not initialised yet?");
+ throw std::logic_error("CConnection::processMsg: not initialised yet?");
default:
- throw Exception("CConnection::processMsg: invalid state");
+ throw std::logic_error("CConnection::processMsg: invalid state");
}
}
diff --git a/common/rfb/CMsgWriter.cxx b/common/rfb/CMsgWriter.cxx
index 1bd8040f..1c801412 100644
--- a/common/rfb/CMsgWriter.cxx
+++ b/common/rfb/CMsgWriter.cxx
@@ -31,7 +31,6 @@
#include <rfb/fenceTypes.h>
#include <rfb/qemuTypes.h>
#include <rfb/clipboardTypes.h>
-#include <rfb/Exception.h>
#include <rfb/PixelFormat.h>
#include <rfb/Rect.h>
#include <rfb/ServerParams.h>
@@ -77,7 +76,7 @@ void CMsgWriter::writeSetDesktopSize(int width, int height,
const ScreenSet& layout)
{
if (!server->supportsSetDesktopSize)
- throw Exception("Server does not support SetDesktopSize");
+ throw std::logic_error("Server does not support SetDesktopSize");
startMsg(msgTypeSetDesktopSize);
os->pad(1);
@@ -116,7 +115,7 @@ void CMsgWriter::writeEnableContinuousUpdates(bool enable,
int x, int y, int w, int h)
{
if (!server->supportsContinuousUpdates)
- throw Exception("Server does not support continuous updates");
+ throw std::logic_error("Server does not support continuous updates");
startMsg(msgTypeEnableContinuousUpdates);
@@ -133,11 +132,11 @@ void CMsgWriter::writeEnableContinuousUpdates(bool enable,
void CMsgWriter::writeFence(uint32_t flags, unsigned len, const uint8_t data[])
{
if (!server->supportsFence)
- throw Exception("Server does not support fences");
+ throw std::logic_error("Server does not support fences");
if (len > 64)
- throw Exception("Too large fence payload");
+ throw std::out_of_range("Too large fence payload");
if ((flags & ~fenceFlagsSupported) != 0)
- throw Exception("Unknown fence flags");
+ throw std::invalid_argument("Unknown fence flags");
startMsg(msgTypeClientFence);
os->pad(3);
@@ -192,7 +191,7 @@ void CMsgWriter::writePointerEvent(const Point& pos, uint8_t buttonMask)
void CMsgWriter::writeClientCutText(const char* str)
{
if (strchr(str, '\r') != nullptr)
- throw Exception("Invalid carriage return in clipboard data");
+ throw std::invalid_argument("Invalid carriage return in clipboard data");
std::string latin1(utf8ToLatin1(str));
@@ -209,7 +208,7 @@ void CMsgWriter::writeClipboardCaps(uint32_t caps,
size_t i, count;
if (!(server->clipboardFlags() & clipboardCaps))
- throw Exception("Server does not support clipboard \"caps\" action");
+ throw std::logic_error("Server does not support clipboard \"caps\" action");
count = 0;
for (i = 0;i < 16;i++) {
@@ -235,7 +234,7 @@ void CMsgWriter::writeClipboardCaps(uint32_t caps,
void CMsgWriter::writeClipboardRequest(uint32_t flags)
{
if (!(server->clipboardFlags() & clipboardRequest))
- throw Exception("Server does not support clipboard \"request\" action");
+ throw std::logic_error("Server does not support clipboard \"request\" action");
startMsg(msgTypeClientCutText);
os->pad(3);
@@ -247,7 +246,7 @@ void CMsgWriter::writeClipboardRequest(uint32_t flags)
void CMsgWriter::writeClipboardPeek(uint32_t flags)
{
if (!(server->clipboardFlags() & clipboardPeek))
- throw Exception("Server does not support clipboard \"peek\" action");
+ throw std::logic_error("Server does not support clipboard \"peek\" action");
startMsg(msgTypeClientCutText);
os->pad(3);
@@ -259,7 +258,7 @@ void CMsgWriter::writeClipboardPeek(uint32_t flags)
void CMsgWriter::writeClipboardNotify(uint32_t flags)
{
if (!(server->clipboardFlags() & clipboardNotify))
- throw Exception("Server does not support clipboard \"notify\" action");
+ throw std::logic_error("Server does not support clipboard \"notify\" action");
startMsg(msgTypeClientCutText);
os->pad(3);
@@ -278,7 +277,7 @@ void CMsgWriter::writeClipboardProvide(uint32_t flags,
int i, count;
if (!(server->clipboardFlags() & clipboardProvide))
- throw Exception("Server does not support clipboard \"provide\" action");
+ throw std::logic_error("Server does not support clipboard \"provide\" action");
zos.setUnderlying(&mos);
diff --git a/common/rfb/CSecurityDH.cxx b/common/rfb/CSecurityDH.cxx
index 6eafbd9c..e37a3a33 100644
--- a/common/rfb/CSecurityDH.cxx
+++ b/common/rfb/CSecurityDH.cxx
@@ -112,7 +112,7 @@ void CSecurityDH::writeCredentials()
std::vector<uint8_t> bBytes(keyLength);
if (!rs.hasData(keyLength))
- throw Exception("failed to generate DH private key");
+ throw std::runtime_error("failed to generate DH private key");
rs.readBytes(bBytes.data(), bBytes.size());
nettle_mpz_set_str_256_u(b, bBytes.size(), bBytes.data());
mpz_powm(k, A, b, p);
@@ -132,13 +132,13 @@ void CSecurityDH::writeCredentials()
uint8_t buf[128];
if (!rs.hasData(128))
- throw Exception("failed to generate random padding");
+ throw std::runtime_error("failed to generate random padding");
rs.readBytes(buf, 128);
if (username.size() >= 64)
- throw Exception("username is too long");
+ throw std::out_of_range("username is too long");
memcpy(buf, username.c_str(), username.size() + 1);
if (password.size() >= 64)
- throw Exception("password is too long");
+ throw std::out_of_range("password is too long");
memcpy(buf + 64, password.c_str(), password.size() + 1);
aes128_encrypt(&aesCtx, 128, buf, buf);
diff --git a/common/rfb/CSecurityMSLogonII.cxx b/common/rfb/CSecurityMSLogonII.cxx
index f8ff36c1..85736b44 100644
--- a/common/rfb/CSecurityMSLogonII.cxx
+++ b/common/rfb/CSecurityMSLogonII.cxx
@@ -39,7 +39,6 @@
#include <rdr/InStream.h>
#include <rdr/OutStream.h>
#include <rdr/RandomStream.h>
-#include <rfb/Exception.h>
#include <os/os.h>
using namespace rfb;
@@ -101,7 +100,7 @@ void CSecurityMSLogonII::writeCredentials()
std::vector<uint8_t> bBytes(8);
if (!rs.hasData(8))
- throw Exception("failed to generate DH private key");
+ throw std::runtime_error("failed to generate DH private key");
rs.readBytes(bBytes.data(), bBytes.size());
nettle_mpz_set_str_256_u(b, bBytes.size(), bBytes.data());
mpz_powm(k, A, b, p);
@@ -123,14 +122,14 @@ void CSecurityMSLogonII::writeCredentials()
}
if (!rs.hasData(256 + 64))
- throw Exception("failed to generate random padding");
+ throw std::runtime_error("failed to generate random padding");
rs.readBytes(user, 256);
rs.readBytes(pass, 64);
if (username.size() >= 256)
- throw Exception("username is too long");
+ throw std::out_of_range("username is too long");
memcpy(user, username.c_str(), username.size() + 1);
if (password.size() >= 64)
- throw Exception("password is too long");
+ throw std::out_of_range("password is too long");
memcpy(pass, password.c_str(), password.size() + 1);
// DES-CBC with the original key as IV, and the reversed one as the DES key
diff --git a/common/rfb/CSecurityRSAAES.cxx b/common/rfb/CSecurityRSAAES.cxx
index 4baeb235..37b59532 100644
--- a/common/rfb/CSecurityRSAAES.cxx
+++ b/common/rfb/CSecurityRSAAES.cxx
@@ -134,7 +134,7 @@ static void random_func(void* ctx, size_t length, uint8_t* dst)
{
rdr::RandomStream* rs = (rdr::RandomStream*)ctx;
if (!rs->hasData(length))
- throw Exception("failed to generate random");
+ throw std::runtime_error("failed to generate random");
rs->readBytes(dst, length);
}
@@ -155,7 +155,7 @@ void CSecurityRSAAES::writePublicKey()
if (!rsa_generate_keypair(&clientPublicKey, &clientKey,
&rs, random_func, nullptr, nullptr,
clientKeyLength, 0))
- throw Exception("failed to generate key");
+ throw std::runtime_error("failed to generate key");
clientKeyN = new uint8_t[rsaKeySize];
clientKeyE = new uint8_t[rsaKeySize];
nettle_mpz_get_str_256(rsaKeySize, clientKeyN, clientPublicKey.n);
@@ -222,7 +222,7 @@ void CSecurityRSAAES::writeRandom()
{
rdr::OutStream* os = cc->getOutStream();
if (!rs.hasData(keySize / 8))
- throw Exception("failed to generate random");
+ throw std::runtime_error("failed to generate random");
rs.readBytes(clientRandom, keySize / 8);
mpz_t x;
mpz_init(x);
@@ -236,7 +236,7 @@ void CSecurityRSAAES::writeRandom()
}
if (!res) {
mpz_clear(x);
- throw Exception("failed to encrypt random");
+ throw std::runtime_error("failed to encrypt random");
}
uint8_t* buffer = new uint8_t[serverKey.size];
nettle_mpz_get_str_256(serverKey.size, buffer, x);
@@ -443,7 +443,7 @@ void CSecurityRSAAES::writeCredentials()
if (subtype == secTypeRA2UserPass) {
if (username.size() > 255)
- throw Exception("username is too long");
+ throw std::out_of_range("username is too long");
raos->writeU8(username.size());
raos->writeBytes((const uint8_t*)username.data(), username.size());
} else {
@@ -451,7 +451,7 @@ void CSecurityRSAAES::writeCredentials()
}
if (password.size() > 255)
- throw Exception("password is too long");
+ throw std::out_of_range("password is too long");
raos->writeU8(password.size());
raos->writeBytes((const uint8_t*)password.data(), password.size());
raos->flush();
diff --git a/common/rfb/CSecurityTLS.cxx b/common/rfb/CSecurityTLS.cxx
index 2722415b..ae916139 100644
--- a/common/rfb/CSecurityTLS.cxx
+++ b/common/rfb/CSecurityTLS.cxx
@@ -387,8 +387,8 @@ void CSecurityTLS::checkSession()
hostsDir = os::getvncstatedir();
if (hostsDir == nullptr) {
- throw Exception("Could not obtain VNC state directory path for "
- "known hosts storage");
+ throw std::runtime_error("Could not obtain VNC state directory "
+ "path for known hosts storage");
}
std::string dbPath;
@@ -509,7 +509,7 @@ void CSecurityTLS::checkSession()
if (status != 0) {
vlog.error("Unhandled certificate problems: 0x%x", status);
- throw Exception("Unhandled certificate problems");
+ throw std::logic_error("Unhandled certificate problems");
}
if (!hostname_match) {
@@ -625,7 +625,7 @@ void CSecurityTLS::checkSession()
if (status != 0) {
vlog.error("Unhandled certificate problems: 0x%x", status);
- throw Exception("Unhandled certificate problems");
+ throw std::logic_error("Unhandled certificate problems");
}
if (!hostname_match) {
diff --git a/common/rfb/ClientParams.cxx b/common/rfb/ClientParams.cxx
index 3f80f109..495b4bd1 100644
--- a/common/rfb/ClientParams.cxx
+++ b/common/rfb/ClientParams.cxx
@@ -22,7 +22,8 @@
#include <config.h>
#endif
-#include <rfb/Exception.h>
+#include <stdexcept>
+
#include <rfb/encodings.h>
#include <rfb/ledStates.h>
#include <rfb/clipboardTypes.h>
@@ -63,7 +64,7 @@ void ClientParams::setDimensions(int width, int height)
void ClientParams::setDimensions(int width, int height, const ScreenSet& layout)
{
if (!layout.validate(width, height))
- throw Exception("Attempted to configure an invalid screen layout");
+ throw std::invalid_argument("Attempted to configure an invalid screen layout");
width_ = width;
height_ = height;
@@ -75,7 +76,7 @@ void ClientParams::setPF(const PixelFormat& pf)
pf_ = pf;
if (pf.bpp != 8 && pf.bpp != 16 && pf.bpp != 32)
- throw Exception("setPF: not 8, 16 or 32 bpp?");
+ throw std::invalid_argument("setPF: not 8, 16 or 32 bpp?");
}
void ClientParams::setName(const char* name)
@@ -161,7 +162,7 @@ uint32_t ClientParams::clipboardSize(unsigned int format) const
return clipSizes[i];
}
- throw Exception(rfb::format("Invalid clipboard format 0x%x", format));
+ throw std::invalid_argument(rfb::format("Invalid clipboard format 0x%x", format));
}
void ClientParams::setClipboardCaps(uint32_t flags, const uint32_t* lengths)
diff --git a/common/rfb/Configuration.cxx b/common/rfb/Configuration.cxx
index f58a9c2f..8f7cb6a7 100644
--- a/common/rfb/Configuration.cxx
+++ b/common/rfb/Configuration.cxx
@@ -30,12 +30,13 @@
#include <ctype.h>
#include <string.h>
+#include <stdexcept>
+
#include <os/Mutex.h>
#include <rfb/util.h>
#include <rfb/Configuration.h>
#include <rfb/LogWriter.h>
-#include <rfb/Exception.h>
#define LOCK_CONFIG os::AutoMutex a(mutex)
@@ -376,7 +377,7 @@ StringParameter::StringParameter(const char* name_, const char* desc_,
{
if (!v) {
vlog.error("Default value <null> for %s not allowed",name_);
- throw rfb::Exception("Default value <null> not allowed");
+ throw std::invalid_argument("Default value <null> not allowed");
}
}
@@ -387,7 +388,7 @@ bool StringParameter::setParam(const char* v) {
LOCK_CONFIG;
if (immutable) return true;
if (!v)
- throw rfb::Exception("setParam(<null>) not allowed");
+ throw std::invalid_argument("setParam(<null>) not allowed");
vlog.debug("set %s(String) to %s", getName(), v);
value = v;
return true;
diff --git a/common/rfb/Cursor.cxx b/common/rfb/Cursor.cxx
index fa596bc5..94844144 100644
--- a/common/rfb/Cursor.cxx
+++ b/common/rfb/Cursor.cxx
@@ -24,9 +24,10 @@
#include <assert.h>
#include <string.h>
+#include <stdexcept>
+
#include <rfb/Cursor.h>
#include <rfb/LogWriter.h>
-#include <rfb/Exception.h>
using namespace rfb;
@@ -260,7 +261,7 @@ const uint8_t* RenderedCursor::getBuffer(const Rect& _r, int* stride) const
r = _r.translate(offset.negate());
if (!r.enclosed_by(buffer.getRect()))
- throw Exception("RenderedCursor: Invalid area requested");
+ throw std::out_of_range("RenderedCursor: Invalid area requested");
return buffer.getBuffer(r, stride);
}
diff --git a/common/rfb/DecodeManager.cxx b/common/rfb/DecodeManager.cxx
index 6000063f..2b121ebe 100644
--- a/common/rfb/DecodeManager.cxx
+++ b/common/rfb/DecodeManager.cxx
@@ -149,7 +149,7 @@ bool DecodeManager::decodeRect(const Rect& r, int encoding,
if (!decoder->readRect(r, conn->getInStream(), conn->server, bufferStream))
return false;
} catch (std::exception& e) {
- throw Exception(format("Error reading rect: %s", e.what()));
+ throw std::runtime_error(format("Error reading rect: %s", e.what()));
}
stats[encoding].rects++;
@@ -250,7 +250,7 @@ void DecodeManager::setThreadException(const std::exception& e)
if (threadException != nullptr)
return;
- threadException = new rdr::Exception(format("Exception on worker thread: %s", e.what()));
+ threadException = new std::runtime_error(format("Exception on worker thread: %s", e.what()));
}
void DecodeManager::throwThreadException()
diff --git a/common/rfb/EncodeManager.cxx b/common/rfb/EncodeManager.cxx
index 5c1429d2..4526c0b3 100644
--- a/common/rfb/EncodeManager.cxx
+++ b/common/rfb/EncodeManager.cxx
@@ -32,7 +32,6 @@
#include <rfb/SMsgWriter.h>
#include <rfb/UpdateTracker.h>
#include <rfb/LogWriter.h>
-#include <rfb/Exception.h>
#include <rfb/util.h>
#include <rfb/RawEncoder.h>
@@ -1055,7 +1054,7 @@ void EncodeManager::OffsetPixelBuffer::update(const PixelFormat& pf,
uint8_t* EncodeManager::OffsetPixelBuffer::getBufferRW(const Rect& /*r*/, int* /*stride*/)
{
- throw rfb::Exception("Invalid write attempt to OffsetPixelBuffer");
+ throw std::logic_error("Invalid write attempt to OffsetPixelBuffer");
}
template<class T>
diff --git a/common/rfb/H264Decoder.cxx b/common/rfb/H264Decoder.cxx
index 3178a17b..89850ba4 100644
--- a/common/rfb/H264Decoder.cxx
+++ b/common/rfb/H264Decoder.cxx
@@ -30,7 +30,6 @@
#include <rdr/InStream.h>
#include <rdr/OutStream.h>
#include <rfb/LogWriter.h>
-#include <rfb/Exception.h>
#include <rfb/H264Decoder.h>
#include <rfb/H264DecoderContext.h>
@@ -128,12 +127,12 @@ void H264Decoder::decodeRect(const Rect& r, const uint8_t* buffer,
}
ctx = H264DecoderContext::createContext(r);
if (!ctx)
- throw Exception("H264Decoder: Context not be created");
+ throw std::runtime_error("H264Decoder: Context not be created");
contexts.push_back(ctx);
}
if (!ctx->isReady())
- throw Exception("H264Decoder: Context is not ready");
+ throw std::runtime_error("H264Decoder: Context is not ready");
if (reset & resetContext)
ctx->reset();
diff --git a/common/rfb/H264DecoderContext.cxx b/common/rfb/H264DecoderContext.cxx
index 87ac0d85..b2054554 100644
--- a/common/rfb/H264DecoderContext.cxx
+++ b/common/rfb/H264DecoderContext.cxx
@@ -22,8 +22,9 @@
#include <config.h>
#endif
+#include <stdexcept>
+
#include <os/Mutex.h>
-#include <rfb/Exception.h>
#include <rfb/LogWriter.h>
#include <rfb/H264DecoderContext.h>
@@ -45,7 +46,7 @@ H264DecoderContext *H264DecoderContext::createContext(const Rect &r)
H264DecoderContext *ret = new H264DecoderContextType(r);
if (!ret->initCodec())
{
- throw Exception("H264DecoderContext: Unable to create context");
+ throw std::runtime_error("H264DecoderContext: Unable to create context");
}
return ret;
diff --git a/common/rfb/H264LibavDecoderContext.cxx b/common/rfb/H264LibavDecoderContext.cxx
index fa2f367b..2d8d03e7 100644
--- a/common/rfb/H264LibavDecoderContext.cxx
+++ b/common/rfb/H264LibavDecoderContext.cxx
@@ -33,7 +33,6 @@ extern "C" {
#define FFMPEG_INIT_PACKET_DEPRECATED
#endif
-#include <rfb/Exception.h>
#include <rfb/LogWriter.h>
#include <rfb/PixelBuffer.h>
#include <rfb/H264LibavDecoderContext.h>
@@ -118,7 +117,7 @@ uint8_t* H264LibavDecoderContext::makeH264WorkBuffer(const uint8_t* buffer, uint
{
h264WorkBuffer = (uint8_t*)realloc(h264WorkBuffer, reserve_len);
if (h264WorkBuffer == nullptr) {
- throw Exception("H264LibavDecoderContext: Unable to allocate memory");
+ throw std::bad_alloc();
}
h264WorkBufferLength = reserve_len;
}
diff --git a/common/rfb/Hostname.h b/common/rfb/Hostname.h
index f6a11a60..de4a330e 100644
--- a/common/rfb/Hostname.h
+++ b/common/rfb/Hostname.h
@@ -23,7 +23,9 @@
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
-#include <rdr/Exception.h>
+
+#include <stdexcept>
+
#include <rfb/util.h>
namespace rfb {
@@ -47,7 +49,7 @@ namespace rfb {
const char* portStart;
if (hi == nullptr)
- throw rdr::Exception("NULL host specified");
+ throw std::invalid_argument("NULL host specified");
// Trim leading whitespace
while(isspace(*hi))
@@ -60,7 +62,7 @@ namespace rfb {
hostStart = &hi[1];
hostEnd = strchr(hostStart, ']');
if (hostEnd == nullptr)
- throw rdr::Exception("unmatched [ in host");
+ throw std::invalid_argument("unmatched [ in host");
portStart = hostEnd + 1;
if (isAllSpace(portStart))
@@ -99,14 +101,14 @@ namespace rfb {
char* end;
if (portStart[0] != ':')
- throw rdr::Exception("invalid port specified");
+ throw std::invalid_argument("invalid port specified");
if (portStart[1] != ':')
*port = strtol(portStart + 1, &end, 10);
else
*port = strtol(portStart + 2, &end, 10);
if (*end != '\0' && ! isAllSpace(end))
- throw rdr::Exception("invalid port specified");
+ throw std::invalid_argument("invalid port specified");
if ((portStart[1] != ':') && (*port < 100))
*port += basePort;
diff --git a/common/rfb/JpegCompressor.cxx b/common/rfb/JpegCompressor.cxx
index 49ed4b61..67a86cd9 100644
--- a/common/rfb/JpegCompressor.cxx
+++ b/common/rfb/JpegCompressor.cxx
@@ -22,8 +22,9 @@
#include <config.h>
#endif
+#include <stdexcept>
+
#include <rfb/JpegCompressor.h>
-#include <rdr/Exception.h>
#include <rfb/Rect.h>
#include <rfb/PixelFormat.h>
#include <rfb/ClientParams.h>
@@ -127,7 +128,7 @@ JpegCompressor::JpegCompressor(int bufferLen) : MemOutStream(bufferLen)
if(setjmp(err->jmpBuffer)) {
// this will execute if libjpeg has an error
- throw rdr::Exception(err->lastError);
+ throw std::runtime_error(err->lastError);
}
jpeg_create_compress(cinfo);
@@ -171,7 +172,7 @@ void JpegCompressor::compress(const uint8_t *buf, volatile int stride,
jpeg_abort_compress(cinfo);
if (srcBufIsTemp && srcBuf) delete[] srcBuf;
if (rowPointer) delete[] rowPointer;
- throw rdr::Exception(err->lastError);
+ throw std::runtime_error(err->lastError);
}
cinfo->image_width = w;
@@ -256,5 +257,5 @@ void JpegCompressor::compress(const uint8_t *buf, volatile int stride,
void JpegCompressor::writeBytes(const uint8_t* /*data*/, int /*length*/)
{
- throw rdr::Exception("writeBytes() is not valid with a JpegCompressor instance. Use compress() instead.");
+ throw std::logic_error("writeBytes() is not valid with a JpegCompressor instance. Use compress() instead.");
}
diff --git a/common/rfb/JpegDecompressor.cxx b/common/rfb/JpegDecompressor.cxx
index 4b3b4db7..9406b43d 100644
--- a/common/rfb/JpegDecompressor.cxx
+++ b/common/rfb/JpegDecompressor.cxx
@@ -120,7 +120,7 @@ JpegDecompressor::JpegDecompressor(void)
if(setjmp(err->jmpBuffer)) {
// this will execute if libjpeg has an error
- throw rdr::Exception(err->lastError);
+ throw std::runtime_error(err->lastError);
}
jpeg_create_decompress(dinfo);
@@ -168,7 +168,7 @@ void JpegDecompressor::decompress(const uint8_t *jpegBuf,
jpeg_abort_decompress(dinfo);
if (dstBufIsTemp && dstBuf) delete[] dstBuf;
if (rowPointer) delete[] rowPointer;
- throw rdr::Exception(err->lastError);
+ throw std::runtime_error(err->lastError);
}
src->pub.next_input_byte = jpegBuf;
diff --git a/common/rfb/PixelBuffer.cxx b/common/rfb/PixelBuffer.cxx
index ca2a5845..5590c214 100644
--- a/common/rfb/PixelBuffer.cxx
+++ b/common/rfb/PixelBuffer.cxx
@@ -28,7 +28,8 @@
#include <string.h>
-#include <rfb/Exception.h>
+#include <stdexcept>
+
#include <rfb/LogWriter.h>
#include <rfb/PixelBuffer.h>
#include <rfb/util.h>
@@ -71,10 +72,10 @@ PixelBuffer::getImage(void* imageBuf, const Rect& r, int outStride) const
const uint8_t* end;
if (!r.enclosed_by(getRect()))
- throw rfb::Exception(rfb::format("Source rect %dx%d at %d,%d exceeds framebuffer %dx%d",
- r.width(), r.height(),
- r.tl.x, r.tl.y,
- width(), height()));
+ throw std::out_of_range(rfb::format("Source rect %dx%d at %d,%d exceeds framebuffer %dx%d",
+ r.width(), r.height(),
+ r.tl.x, r.tl.y,
+ width(), height()));
data = getBuffer(r, &inStride);
@@ -108,10 +109,10 @@ void PixelBuffer::getImage(const PixelFormat& pf, void* imageBuf,
}
if (!r.enclosed_by(getRect()))
- throw rfb::Exception(rfb::format("Source rect %dx%d at %d,%d exceeds framebuffer %dx%d",
- r.width(), r.height(),
- r.tl.x, r.tl.y,
- width(), height()));
+ throw std::out_of_range(rfb::format("Source rect %dx%d at %d,%d exceeds framebuffer %dx%d",
+ r.width(), r.height(),
+ r.tl.x, r.tl.y,
+ width(), height()));
if (stride == 0)
stride = r.width();
@@ -125,9 +126,9 @@ void PixelBuffer::getImage(const PixelFormat& pf, void* imageBuf,
void PixelBuffer::setSize(int width, int height)
{
if ((width < 0) || (width > maxPixelBufferWidth))
- throw rfb::Exception(rfb::format("Invalid PixelBuffer width of %d pixels requested", width));
+ throw std::out_of_range(rfb::format("Invalid PixelBuffer width of %d pixels requested", width));
if ((height < 0) || (height > maxPixelBufferHeight))
- throw rfb::Exception(rfb::format("Invalid PixelBuffer height of %d pixels requested", height));
+ throw std::out_of_range(rfb::format("Invalid PixelBuffer height of %d pixels requested", height));
width_ = width;
height_ = height;
@@ -156,10 +157,10 @@ void ModifiablePixelBuffer::fillRect(const Rect& r, const void* pix)
int w, h, b;
if (!r.enclosed_by(getRect()))
- throw rfb::Exception(rfb::format("Destination rect %dx%d at %d,%d exceeds framebuffer %dx%d",
- r.width(), r.height(),
- r.tl.x, r.tl.y,
- width(), height()));
+ throw std::out_of_range(rfb::format("Destination rect %dx%d at %d,%d exceeds framebuffer %dx%d",
+ r.width(), r.height(),
+ r.tl.x, r.tl.y,
+ width(), height()));
w = r.width();
h = r.height();
@@ -208,10 +209,10 @@ void ModifiablePixelBuffer::imageRect(const Rect& r,
uint8_t* end;
if (!r.enclosed_by(getRect()))
- throw rfb::Exception(rfb::format("Destination rect %dx%d at %d,%d exceeds framebuffer %dx%d",
- r.width(), r.height(),
- r.tl.x, r.tl.y,
- width(), height()));
+ throw std::out_of_range(rfb::format("Destination rect %dx%d at %d,%d exceeds framebuffer %dx%d",
+ r.width(), r.height(),
+ r.tl.x, r.tl.y,
+ width(), height()));
bytesPerPixel = getPF().bpp/8;
@@ -248,17 +249,17 @@ void ModifiablePixelBuffer::copyRect(const Rect &rect,
drect = rect;
if (!drect.enclosed_by(getRect()))
- throw rfb::Exception(rfb::format("Destination rect %dx%d at %d,%d exceeds framebuffer %dx%d",
- drect.width(), drect.height(),
- drect.tl.x, drect.tl.y,
- width(), height()));
+ throw std::out_of_range(rfb::format("Destination rect %dx%d at %d,%d exceeds framebuffer %dx%d",
+ drect.width(), drect.height(),
+ drect.tl.x, drect.tl.y,
+ width(), height()));
srect = drect.translate(move_by_delta.negate());
if (!srect.enclosed_by(getRect()))
- throw rfb::Exception(rfb::format("Source rect %dx%d at %d,%d exceeds framebuffer %dx%d",
- srect.width(), srect.height(),
- srect.tl.x, srect.tl.y,
- width(), height()));
+ throw std::out_of_range(rfb::format("Source rect %dx%d at %d,%d exceeds framebuffer %dx%d",
+ srect.width(), srect.height(),
+ srect.tl.x, srect.tl.y,
+ width(), height()));
bytesPerPixel = format.bpp/8;
@@ -311,10 +312,10 @@ void ModifiablePixelBuffer::imageRect(const PixelFormat& pf, const Rect &dest,
int dstStride;
if (!dest.enclosed_by(getRect()))
- throw rfb::Exception(rfb::format("Destination rect %dx%d at %d,%d exceeds framebuffer %dx%d",
- dest.width(), dest.height(),
- dest.tl.x, dest.tl.y,
- width(), height()));
+ throw std::out_of_range(rfb::format("Destination rect %dx%d at %d,%d exceeds framebuffer %dx%d",
+ dest.width(), dest.height(),
+ dest.tl.x, dest.tl.y,
+ width(), height()));
if (stride == 0)
stride = dest.width();
@@ -341,10 +342,10 @@ FullFramePixelBuffer::~FullFramePixelBuffer() {}
uint8_t* FullFramePixelBuffer::getBufferRW(const Rect& r, int* stride_)
{
if (!r.enclosed_by(getRect()))
- throw rfb::Exception(rfb::format("Pixel buffer request %dx%d at %d,%d exceeds framebuffer %dx%d",
- r.width(), r.height(),
- r.tl.x, r.tl.y,
- width(), height()));
+ throw std::out_of_range(rfb::format("Pixel buffer request %dx%d at %d,%d exceeds framebuffer %dx%d",
+ r.width(), r.height(),
+ r.tl.x, r.tl.y,
+ width(), height()));
*stride_ = stride;
return &data[(r.tl.x + (r.tl.y * stride)) * (format.bpp/8)];
@@ -357,10 +358,10 @@ void FullFramePixelBuffer::commitBufferRW(const Rect& /*r*/)
const uint8_t* FullFramePixelBuffer::getBuffer(const Rect& r, int* stride_) const
{
if (!r.enclosed_by(getRect()))
- throw rfb::Exception(rfb::format("Pixel buffer request %dx%d at %d,%d exceeds framebuffer %dx%d",
- r.width(), r.height(),
- r.tl.x, r.tl.y,
- width(), height()));
+ throw std::out_of_range(rfb::format("Pixel buffer request %dx%d at %d,%d exceeds framebuffer %dx%d",
+ r.width(), r.height(),
+ r.tl.x, r.tl.y,
+ width(), height()));
*stride_ = stride;
return &data[(r.tl.x + (r.tl.y * stride)) * (format.bpp/8)];
@@ -370,13 +371,13 @@ void FullFramePixelBuffer::setBuffer(int width, int height,
uint8_t* data_, int stride_)
{
if ((width < 0) || (width > maxPixelBufferWidth))
- throw rfb::Exception(rfb::format("Invalid PixelBuffer width of %d pixels requested", width));
+ throw std::out_of_range(rfb::format("Invalid PixelBuffer width of %d pixels requested", width));
if ((height < 0) || (height > maxPixelBufferHeight))
- throw rfb::Exception(rfb::format("Invalid PixelBuffer height of %d pixels requested", height));
+ throw std::out_of_range(rfb::format("Invalid PixelBuffer height of %d pixels requested", height));
if ((stride_ < 0) || (stride_ > maxPixelBufferStride) || (stride_ < width))
- throw rfb::Exception(rfb::format("Invalid PixelBuffer stride of %d pixels requested", stride_));
+ throw std::invalid_argument(rfb::format("Invalid PixelBuffer stride of %d pixels requested", stride_));
if ((width != 0) && (height != 0) && (data_ == nullptr))
- throw rfb::Exception(rfb::format("PixelBuffer requested without a valid memory area"));
+ throw std::logic_error(rfb::format("PixelBuffer requested without a valid memory area"));
ModifiablePixelBuffer::setSize(width, height);
stride = stride_;
@@ -386,7 +387,7 @@ void FullFramePixelBuffer::setBuffer(int width, int height,
void FullFramePixelBuffer::setSize(int /*w*/, int /*h*/)
{
// setBuffer() should be used
- throw rfb::Exception("Invalid call to FullFramePixelBuffer::setSize()");
+ throw std::logic_error("Invalid call to FullFramePixelBuffer::setSize()");
}
// -=- Managed pixel buffer class
diff --git a/common/rfb/PixelFormat.cxx b/common/rfb/PixelFormat.cxx
index b90fc206..f883cbf5 100644
--- a/common/rfb/PixelFormat.cxx
+++ b/common/rfb/PixelFormat.cxx
@@ -86,7 +86,7 @@ PixelFormat::PixelFormat(int b, int d, bool e, bool t,
redShift(rs), greenShift(gs), blueShift(bs)
{
if (!isSane())
- throw Exception("invalid pixel format");
+ throw std::invalid_argument("invalid pixel format");
updateState();
}
diff --git a/common/rfb/SConnection.cxx b/common/rfb/SConnection.cxx
index c43ed493..cf9dde05 100644
--- a/common/rfb/SConnection.cxx
+++ b/common/rfb/SConnection.cxx
@@ -95,14 +95,14 @@ bool SConnection::processMsg()
case RFBSTATE_INITIALISATION: return processInitMsg(); break;
case RFBSTATE_NORMAL: return reader_->readMsg(); break;
case RFBSTATE_QUERYING:
- throw Exception("SConnection::processMsg: bogus data from client while "
- "querying");
+ throw std::logic_error("SConnection::processMsg: bogus data from "
+ "client while querying");
case RFBSTATE_CLOSING:
- throw Exception("SConnection::processMsg: called while closing");
+ throw std::logic_error("SConnection::processMsg: called while closing");
case RFBSTATE_UNINITIALISED:
- throw Exception("SConnection::processMsg: not initialised yet?");
+ throw std::logic_error("SConnection::processMsg: not initialised yet?");
default:
- throw Exception("SConnection::processMsg: invalid state");
+ throw std::logic_error("SConnection::processMsg: invalid state");
}
}
@@ -336,7 +336,7 @@ void SConnection::setAccessRights(AccessRights ar)
bool SConnection::accessCheck(AccessRights ar) const
{
if (state_ < RFBSTATE_QUERYING)
- throw Exception("SConnection::accessCheck: invalid state");
+ throw std::logic_error("SConnection::accessCheck: invalid state");
return (accessRights & ar) == ar;
}
@@ -449,7 +449,7 @@ void SConnection::queryConnection(const char* /*userName*/)
void SConnection::approveConnection(bool accept, const char* reason)
{
if (state_ != RFBSTATE_QUERYING)
- throw Exception("SConnection::approveConnection: invalid state");
+ throw std::logic_error("SConnection::approveConnection: invalid state");
if (!client.beforeVersion(3,8) || ssecurity->getType() != secTypeNone) {
if (accept) {
diff --git a/common/rfb/SMsgWriter.cxx b/common/rfb/SMsgWriter.cxx
index 0c03b51d..f525d25a 100644
--- a/common/rfb/SMsgWriter.cxx
+++ b/common/rfb/SMsgWriter.cxx
@@ -31,7 +31,6 @@
#include <rfb/msgTypes.h>
#include <rfb/fenceTypes.h>
#include <rfb/clipboardTypes.h>
-#include <rfb/Exception.h>
#include <rfb/ClientParams.h>
#include <rfb/UpdateTracker.h>
#include <rfb/Encoder.h>
@@ -94,7 +93,7 @@ void SMsgWriter::writeBell()
void SMsgWriter::writeServerCutText(const char* str)
{
if (strchr(str, '\r') != nullptr)
- throw Exception("Invalid carriage return in clipboard data");
+ throw std::invalid_argument("Invalid carriage return in clipboard data");
std::string latin1(utf8ToLatin1(str));
@@ -111,7 +110,7 @@ void SMsgWriter::writeClipboardCaps(uint32_t caps,
size_t i, count;
if (!client->supportsEncoding(pseudoEncodingExtendedClipboard))
- throw Exception("Client does not support extended clipboard");
+ throw std::logic_error("Client does not support extended clipboard");
count = 0;
for (i = 0;i < 16;i++) {
@@ -137,9 +136,9 @@ void SMsgWriter::writeClipboardCaps(uint32_t caps,
void SMsgWriter::writeClipboardRequest(uint32_t flags)
{
if (!client->supportsEncoding(pseudoEncodingExtendedClipboard))
- throw Exception("Client does not support extended clipboard");
+ throw std::logic_error("Client does not support extended clipboard");
if (!(client->clipboardFlags() & clipboardRequest))
- throw Exception("Client does not support clipboard \"request\" action");
+ throw std::logic_error("Client does not support clipboard \"request\" action");
startMsg(msgTypeServerCutText);
os->pad(3);
@@ -151,9 +150,9 @@ void SMsgWriter::writeClipboardRequest(uint32_t flags)
void SMsgWriter::writeClipboardPeek(uint32_t flags)
{
if (!client->supportsEncoding(pseudoEncodingExtendedClipboard))
- throw Exception("Client does not support extended clipboard");
+ throw std::logic_error("Client does not support extended clipboard");
if (!(client->clipboardFlags() & clipboardPeek))
- throw Exception("Client does not support clipboard \"peek\" action");
+ throw std::logic_error("Client does not support clipboard \"peek\" action");
startMsg(msgTypeServerCutText);
os->pad(3);
@@ -165,9 +164,9 @@ void SMsgWriter::writeClipboardPeek(uint32_t flags)
void SMsgWriter::writeClipboardNotify(uint32_t flags)
{
if (!client->supportsEncoding(pseudoEncodingExtendedClipboard))
- throw Exception("Client does not support extended clipboard");
+ throw std::logic_error("Client does not support extended clipboard");
if (!(client->clipboardFlags() & clipboardNotify))
- throw Exception("Client does not support clipboard \"notify\" action");
+ throw std::logic_error("Client does not support clipboard \"notify\" action");
startMsg(msgTypeServerCutText);
os->pad(3);
@@ -186,9 +185,9 @@ void SMsgWriter::writeClipboardProvide(uint32_t flags,
int i, count;
if (!client->supportsEncoding(pseudoEncodingExtendedClipboard))
- throw Exception("Client does not support extended clipboard");
+ throw std::logic_error("Client does not support extended clipboard");
if (!(client->clipboardFlags() & clipboardProvide))
- throw Exception("Client does not support clipboard \"provide\" action");
+ throw std::logic_error("Client does not support clipboard \"provide\" action");
zos.setUnderlying(&mos);
@@ -215,11 +214,11 @@ void SMsgWriter::writeFence(uint32_t flags, unsigned len,
const uint8_t data[])
{
if (!client->supportsEncoding(pseudoEncodingFence))
- throw Exception("Client does not support fences");
+ throw std::logic_error("Client does not support fences");
if (len > 64)
- throw Exception("Too large fence payload");
+ throw std::out_of_range("Too large fence payload");
if ((flags & ~fenceFlagsSupported) != 0)
- throw Exception("Unknown fence flags");
+ throw std::invalid_argument("Unknown fence flags");
startMsg(msgTypeServerFence);
os->pad(3);
@@ -237,7 +236,7 @@ void SMsgWriter::writeFence(uint32_t flags, unsigned len,
void SMsgWriter::writeEndOfContinuousUpdates()
{
if (!client->supportsEncoding(pseudoEncodingContinuousUpdates))
- throw Exception("Client does not support continuous updates");
+ throw std::logic_error("Client does not support continuous updates");
startMsg(msgTypeEndOfContinuousUpdates);
endMsg();
@@ -249,7 +248,7 @@ void SMsgWriter::writeDesktopSize(uint16_t reason, uint16_t result)
if (!client->supportsEncoding(pseudoEncodingDesktopSize) &&
!client->supportsEncoding(pseudoEncodingExtendedDesktopSize))
- throw Exception("Client does not support desktop size changes");
+ throw std::logic_error("Client does not support desktop size changes");
msg.reason = reason;
msg.result = result;
@@ -260,7 +259,7 @@ void SMsgWriter::writeDesktopSize(uint16_t reason, uint16_t result)
void SMsgWriter::writeSetDesktopName()
{
if (!client->supportsEncoding(pseudoEncodingDesktopName))
- throw Exception("Client does not support desktop name changes");
+ throw std::logic_error("Client does not support desktop name changes");
needSetDesktopName = true;
}
@@ -271,7 +270,7 @@ void SMsgWriter::writeCursor()
!client->supportsEncoding(pseudoEncodingXCursor) &&
!client->supportsEncoding(pseudoEncodingCursorWithAlpha) &&
!client->supportsEncoding(pseudoEncodingVMwareCursor))
- throw Exception("Client does not support local cursor");
+ throw std::logic_error("Client does not support local cursor");
needCursor = true;
}
@@ -279,7 +278,7 @@ void SMsgWriter::writeCursor()
void SMsgWriter::writeCursorPos()
{
if (!client->supportsEncoding(pseudoEncodingVMwareCursorPosition))
- throw Exception("Client does not support cursor position");
+ throw std::logic_error("Client does not support cursor position");
needCursorPos = true;
}
@@ -288,9 +287,9 @@ void SMsgWriter::writeLEDState()
{
if (!client->supportsEncoding(pseudoEncodingLEDState) &&
!client->supportsEncoding(pseudoEncodingVMwareLEDState))
- throw Exception("Client does not support LED state");
+ throw std::logic_error("Client does not support LED state");
if (client->ledState() == ledUnknown)
- throw Exception("Server has not specified LED state");
+ throw std::logic_error("Server has not specified LED state");
needLEDState = true;
}
@@ -298,7 +297,7 @@ void SMsgWriter::writeLEDState()
void SMsgWriter::writeQEMUKeyEvent()
{
if (!client->supportsEncoding(pseudoEncodingQEMUKeyEvent))
- throw Exception("Client does not support QEMU key events");
+ throw std::logic_error("Client does not support QEMU key events");
needQEMUKeyEvent = true;
}
@@ -379,8 +378,8 @@ void SMsgWriter::writeFramebufferUpdateStart(int nRects)
void SMsgWriter::writeFramebufferUpdateEnd()
{
if (nRectsInUpdate != nRectsInHeader && nRectsInHeader)
- throw Exception("SMsgWriter::writeFramebufferUpdateEnd: "
- "nRects out of sync");
+ throw std::logic_error("SMsgWriter::writeFramebufferUpdateEnd: "
+ "nRects out of sync");
if (nRectsInHeader == 0) {
// Send last rect. marker
@@ -405,7 +404,7 @@ void SMsgWriter::writeCopyRect(const Rect& r, int srcX, int srcY)
void SMsgWriter::startRect(const Rect& r, int encoding)
{
if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
- throw Exception("SMsgWriter::startRect: nRects out of sync");
+ throw std::logic_error("SMsgWriter::startRect: nRects out of sync");
os->writeS16(r.tl.x);
os->writeS16(r.tl.y);
@@ -470,7 +469,7 @@ void SMsgWriter::writePseudoRects()
cursor.hotspot().x, cursor.hotspot().y,
bitmap.data(), mask.data());
} else {
- throw Exception("Client does not support local cursor");
+ throw std::logic_error("Client does not support local cursor");
}
needCursor = false;
@@ -482,7 +481,7 @@ void SMsgWriter::writePseudoRects()
if (client->supportsEncoding(pseudoEncodingVMwareCursorPosition)) {
writeSetVMwareCursorPositionRect(cursorPos.x, cursorPos.y);
} else {
- throw Exception("Client does not support cursor position");
+ throw std::logic_error("Client does not support cursor position");
}
needCursorPos = false;
@@ -519,7 +518,7 @@ void SMsgWriter::writeNoDataRects()
// more after this
writeSetDesktopSizeRect(client->width(), client->height());
} else {
- throw Exception("Client does not support desktop size changes");
+ throw std::logic_error("Client does not support desktop size changes");
}
extendedDesktopSizeMsgs.clear();
@@ -529,9 +528,9 @@ void SMsgWriter::writeNoDataRects()
void SMsgWriter::writeSetDesktopSizeRect(int width, int height)
{
if (!client->supportsEncoding(pseudoEncodingDesktopSize))
- throw Exception("Client does not support desktop resize");
+ throw std::logic_error("Client does not support desktop resize");
if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
- throw Exception("SMsgWriter::writeSetDesktopSizeRect: nRects out of sync");
+ throw std::logic_error("SMsgWriter::writeSetDesktopSizeRect: nRects out of sync");
os->writeS16(0);
os->writeS16(0);
@@ -549,9 +548,9 @@ void SMsgWriter::writeExtendedDesktopSizeRect(uint16_t reason,
ScreenSet::const_iterator si;
if (!client->supportsEncoding(pseudoEncodingExtendedDesktopSize))
- throw Exception("Client does not support extended desktop resize");
+ throw std::logic_error("Client does not support extended desktop resize");
if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
- throw Exception("SMsgWriter::writeExtendedDesktopSizeRect: nRects out of sync");
+ throw std::logic_error("SMsgWriter::writeExtendedDesktopSizeRect: nRects out of sync");
os->writeU16(reason);
os->writeU16(result);
@@ -575,9 +574,9 @@ void SMsgWriter::writeExtendedDesktopSizeRect(uint16_t reason,
void SMsgWriter::writeSetDesktopNameRect(const char *name)
{
if (!client->supportsEncoding(pseudoEncodingDesktopName))
- throw Exception("Client does not support desktop rename");
+ throw std::logic_error("Client does not support desktop rename");
if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
- throw Exception("SMsgWriter::writeSetDesktopNameRect: nRects out of sync");
+ throw std::logic_error("SMsgWriter::writeSetDesktopNameRect: nRects out of sync");
os->writeS16(0);
os->writeS16(0);
@@ -594,9 +593,9 @@ void SMsgWriter::writeSetCursorRect(int width, int height,
const uint8_t* mask)
{
if (!client->supportsEncoding(pseudoEncodingCursor))
- throw Exception("Client does not support local cursors");
+ throw std::logic_error("Client does not support local cursors");
if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
- throw Exception("SMsgWriter::writeSetCursorRect: nRects out of sync");
+ throw std::logic_error("SMsgWriter::writeSetCursorRect: nRects out of sync");
os->writeS16(hotspotX);
os->writeS16(hotspotY);
@@ -613,9 +612,9 @@ void SMsgWriter::writeSetXCursorRect(int width, int height,
const uint8_t* mask)
{
if (!client->supportsEncoding(pseudoEncodingXCursor))
- throw Exception("Client does not support local cursors");
+ throw std::logic_error("Client does not support local cursors");
if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
- throw Exception("SMsgWriter::writeSetXCursorRect: nRects out of sync");
+ throw std::logic_error("SMsgWriter::writeSetXCursorRect: nRects out of sync");
os->writeS16(hotspotX);
os->writeS16(hotspotY);
@@ -639,9 +638,9 @@ void SMsgWriter::writeSetCursorWithAlphaRect(int width, int height,
const uint8_t* data)
{
if (!client->supportsEncoding(pseudoEncodingCursorWithAlpha))
- throw Exception("Client does not support local cursors");
+ throw std::logic_error("Client does not support local cursors");
if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
- throw Exception("SMsgWriter::writeSetCursorWithAlphaRect: nRects out of sync");
+ throw std::logic_error("SMsgWriter::writeSetCursorWithAlphaRect: nRects out of sync");
os->writeS16(hotspotX);
os->writeS16(hotspotY);
@@ -667,9 +666,9 @@ void SMsgWriter::writeSetVMwareCursorRect(int width, int height,
const uint8_t* data)
{
if (!client->supportsEncoding(pseudoEncodingVMwareCursor))
- throw Exception("Client does not support local cursors");
+ throw std::logic_error("Client does not support local cursors");
if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
- throw Exception("SMsgWriter::writeSetVMwareCursorRect: nRects out of sync");
+ throw std::logic_error("SMsgWriter::writeSetVMwareCursorRect: nRects out of sync");
os->writeS16(hotspotX);
os->writeS16(hotspotY);
@@ -687,9 +686,9 @@ void SMsgWriter::writeSetVMwareCursorRect(int width, int height,
void SMsgWriter::writeSetVMwareCursorPositionRect(int hotspotX, int hotspotY)
{
if (!client->supportsEncoding(pseudoEncodingVMwareCursorPosition))
- throw Exception("Client does not support cursor position");
+ throw std::logic_error("Client does not support cursor position");
if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
- throw Exception("SMsgWriter::writeSetVMwareCursorRect: nRects out of sync");
+ throw std::logic_error("SMsgWriter::writeSetVMwareCursorRect: nRects out of sync");
os->writeS16(hotspotX);
os->writeS16(hotspotY);
@@ -702,11 +701,11 @@ void SMsgWriter::writeLEDStateRect(uint8_t state)
{
if (!client->supportsEncoding(pseudoEncodingLEDState) &&
!client->supportsEncoding(pseudoEncodingVMwareLEDState))
- throw Exception("Client does not support LED state updates");
+ throw std::logic_error("Client does not support LED state updates");
if (client->ledState() == ledUnknown)
- throw Exception("Server does not support LED state updates");
+ throw std::logic_error("Server does not support LED state updates");
if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
- throw Exception("SMsgWriter::writeLEDStateRect: nRects out of sync");
+ throw std::logic_error("SMsgWriter::writeLEDStateRect: nRects out of sync");
os->writeS16(0);
os->writeS16(0);
@@ -724,9 +723,9 @@ void SMsgWriter::writeLEDStateRect(uint8_t state)
void SMsgWriter::writeQEMUKeyEventRect()
{
if (!client->supportsEncoding(pseudoEncodingQEMUKeyEvent))
- throw Exception("Client does not support QEMU extended key events");
+ throw std::logic_error("Client does not support QEMU extended key events");
if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
- throw Exception("SMsgWriter::writeQEMUKeyEventRect: nRects out of sync");
+ throw std::logic_error("SMsgWriter::writeQEMUKeyEventRect: nRects out of sync");
os->writeS16(0);
os->writeS16(0);
diff --git a/common/rfb/SSecurityPlain.cxx b/common/rfb/SSecurityPlain.cxx
index e009de39..1115b7ff 100644
--- a/common/rfb/SSecurityPlain.cxx
+++ b/common/rfb/SSecurityPlain.cxx
@@ -87,7 +87,7 @@ bool SSecurityPlain::processMsg()
char password[1024];
if (!valid)
- throw Exception("No password validator configured");
+ throw std::logic_error("No password validator configured");
if (state == 0) {
if (!is->hasData(8))
diff --git a/common/rfb/SSecurityRSAAES.cxx b/common/rfb/SSecurityRSAAES.cxx
index 6dd700ce..10e901fb 100644
--- a/common/rfb/SSecurityRSAAES.cxx
+++ b/common/rfb/SSecurityRSAAES.cxx
@@ -161,7 +161,7 @@ void SSecurityRSAAES::loadPrivateKey()
size_t size = ftell(file);
if (size == 0 || size > MaxKeyFileSize) {
fclose(file);
- throw Exception("size of key file is zero or too big");
+ throw std::runtime_error("size of key file is zero or too big");
}
fseek(file, 0, SEEK_SET);
std::vector<uint8_t> data(size);
@@ -184,7 +184,7 @@ void SSecurityRSAAES::loadPrivateKey()
loadPKCS8Key(der.data(), der.size());
return;
}
- throw Exception("failed to import key");
+ throw std::runtime_error("failed to import key");
}
void SSecurityRSAAES::loadPKCS1Key(const uint8_t* data, size_t size)
@@ -195,7 +195,7 @@ void SSecurityRSAAES::loadPKCS1Key(const uint8_t* data, size_t size)
if (!rsa_keypair_from_der(&pub, &serverKey, 0, size, data)) {
rsa_private_key_clear(&serverKey);
rsa_public_key_clear(&pub);
- throw Exception("failed to import key");
+ throw std::runtime_error("failed to import key");
}
serverKeyLength = serverKey.size * 8;
serverKeyN = new uint8_t[serverKey.size];
@@ -235,7 +235,7 @@ void SSecurityRSAAES::loadPKCS8Key(const uint8_t* data, size_t size)
loadPKCS1Key(i.data, i.length);
return;
failed:
- throw Exception("failed to import key");
+ throw std::runtime_error("failed to import key");
}
bool SSecurityRSAAES::processMsg()
@@ -319,7 +319,7 @@ static void random_func(void* ctx, size_t length, uint8_t* dst)
{
rdr::RandomStream* rs = (rdr::RandomStream*)ctx;
if (!rs->hasData(length))
- throw Exception("failed to encrypt random");
+ throw std::runtime_error("failed to encrypt random");
rs->readBytes(dst, length);
}
@@ -327,7 +327,7 @@ void SSecurityRSAAES::writeRandom()
{
rdr::OutStream* os = sc->getOutStream();
if (!rs.hasData(keySize / 8))
- throw Exception("failed to generate random");
+ throw std::runtime_error("failed to generate random");
rs.readBytes(serverRandom, keySize / 8);
mpz_t x;
mpz_init(x);
@@ -341,7 +341,7 @@ void SSecurityRSAAES::writeRandom()
}
if (!res) {
mpz_clear(x);
- throw Exception("failed to encrypt random");
+ throw std::runtime_error("failed to encrypt random");
}
uint8_t* buffer = new uint8_t[clientKey.size];
nettle_mpz_get_str_256(clientKey.size, buffer, x);
@@ -566,7 +566,7 @@ void SSecurityRSAAES::verifyUserPass()
}
delete valid;
#else
- throw Exception("No password validator configured");
+ throw std::logic_error("No password validator configured");
#endif
}
@@ -577,7 +577,7 @@ void SSecurityRSAAES::verifyPass()
pg->getVncAuthPasswd(&passwd, &passwdReadOnly);
if (passwd.empty())
- throw Exception("No password configured");
+ throw std::runtime_error("No password configured");
if (password == passwd) {
accessRights = AccessDefault;
diff --git a/common/rfb/SSecurityVncAuth.cxx b/common/rfb/SSecurityVncAuth.cxx
index 272c7ca1..b0401840 100644
--- a/common/rfb/SSecurityVncAuth.cxx
+++ b/common/rfb/SSecurityVncAuth.cxx
@@ -83,7 +83,7 @@ bool SSecurityVncAuth::processMsg()
if (!sentChallenge) {
rdr::RandomStream rs;
if (!rs.hasData(vncAuthChallengeSize))
- throw Exception("Could not generate random data for VNC auth challenge");
+ throw std::runtime_error("Could not generate random data for VNC auth challenge");
rs.readBytes(challenge, vncAuthChallengeSize);
os->writeBytes(challenge, vncAuthChallengeSize);
os->flush();
@@ -100,7 +100,7 @@ bool SSecurityVncAuth::processMsg()
pg->getVncAuthPasswd(&passwd, &passwdReadOnly);
if (passwd.empty())
- throw Exception("No password configured");
+ throw std::runtime_error("No password configured");
if (verifyResponse(passwd.c_str())) {
accessRights = AccessDefault;
diff --git a/common/rfb/SecurityClient.cxx b/common/rfb/SecurityClient.cxx
index 9cd3b904..878edde9 100644
--- a/common/rfb/SecurityClient.cxx
+++ b/common/rfb/SecurityClient.cxx
@@ -27,7 +27,6 @@
#include <rfb/CSecurityVeNCrypt.h>
#include <rfb/CSecurityVncAuth.h>
#include <rfb/CSecurityPlain.h>
-#include <rfb/Exception.h>
#include <rfb/Security.h>
#ifdef HAVE_GNUTLS
#include <rfb/CSecurityTLS.h>
@@ -110,5 +109,5 @@ CSecurity* SecurityClient::GetCSecurity(CConnection* cc, uint32_t secType)
}
bail:
- throw Exception("Security type not supported");
+ throw std::invalid_argument("Security type not supported");
}
diff --git a/common/rfb/SecurityServer.cxx b/common/rfb/SecurityServer.cxx
index b5297736..d692f4fc 100644
--- a/common/rfb/SecurityServer.cxx
+++ b/common/rfb/SecurityServer.cxx
@@ -21,7 +21,6 @@
#include <config.h>
#endif
-#include <rfb/Exception.h>
#include <rfb/Security.h>
#include <rfb/SSecurityNone.h>
#include <rfb/SSecurityStack.h>
@@ -90,6 +89,6 @@ SSecurity* SecurityServer::GetSSecurity(SConnection* sc, uint32_t secType)
}
bail:
- throw Exception("Security type not supported");
+ throw std::invalid_argument("Security type not supported");
}
diff --git a/common/rfb/ServerParams.cxx b/common/rfb/ServerParams.cxx
index 2a8d3a8e..df8ad40d 100644
--- a/common/rfb/ServerParams.cxx
+++ b/common/rfb/ServerParams.cxx
@@ -22,7 +22,8 @@
#include <config.h>
#endif
-#include <rfb/Exception.h>
+#include <stdexcept>
+
#include <rfb/ledStates.h>
#include <rfb/ServerParams.h>
#include <rfb/util.h>
@@ -60,7 +61,7 @@ void ServerParams::setDimensions(int width, int height)
void ServerParams::setDimensions(int width, int height, const ScreenSet& layout)
{
if (!layout.validate(width, height))
- throw Exception("Attempted to configure an invalid screen layout");
+ throw std::invalid_argument("Attempted to configure an invalid screen layout");
width_ = width;
height_ = height;
@@ -72,7 +73,7 @@ void ServerParams::setPF(const PixelFormat& pf)
pf_ = pf;
if (pf.bpp != 8 && pf.bpp != 16 && pf.bpp != 32)
- throw Exception("setPF: not 8, 16 or 32 bpp?");
+ throw std::invalid_argument("setPF: not 8, 16 or 32 bpp?");
}
void ServerParams::setName(const char* name)
@@ -100,7 +101,7 @@ uint32_t ServerParams::clipboardSize(unsigned int format) const
return clipSizes[i];
}
- throw Exception(rfb::format("Invalid clipboard format 0x%x", format));
+ throw std::invalid_argument(rfb::format("Invalid clipboard format 0x%x", format));
}
void ServerParams::setClipboardCaps(uint32_t flags, const uint32_t* lengths)
diff --git a/common/rfb/VNCServerST.cxx b/common/rfb/VNCServerST.cxx
index f1ea2958..c2f47476 100644
--- a/common/rfb/VNCServerST.cxx
+++ b/common/rfb/VNCServerST.cxx
@@ -58,7 +58,6 @@
#include <network/Socket.h>
#include <rfb/ComparingUpdateTracker.h>
-#include <rfb/Exception.h>
#include <rfb/KeyRemapper.h>
#include <rfb/KeysymStr.h>
#include <rfb/LogWriter.h>
@@ -224,7 +223,7 @@ void VNCServerST::processSocketReadEvent(network::Socket* sock)
return;
}
}
- throw rdr::Exception("invalid Socket in VNCServerST");
+ throw std::invalid_argument("invalid Socket in VNCServerST");
}
void VNCServerST::processSocketWriteEvent(network::Socket* sock)
@@ -237,7 +236,7 @@ void VNCServerST::processSocketWriteEvent(network::Socket* sock)
return;
}
}
- throw rdr::Exception("invalid Socket in VNCServerST");
+ throw std::invalid_argument("invalid Socket in VNCServerST");
}
void VNCServerST::blockUpdates()
@@ -284,13 +283,13 @@ void VNCServerST::setPixelBuffer(PixelBuffer* pb_, const ScreenSet& layout)
screenLayout = ScreenSet();
if (desktopStarted)
- throw Exception("setPixelBuffer: null PixelBuffer when desktopStarted?");
+ throw std::logic_error("setPixelBuffer: null PixelBuffer when desktopStarted?");
return;
}
if (!layout.validate(pb->width(), pb->height()))
- throw Exception("setPixelBuffer: invalid screen layout");
+ throw std::invalid_argument("setPixelBuffer: invalid screen layout");
screenLayout = layout;
@@ -342,9 +341,9 @@ void VNCServerST::setPixelBuffer(PixelBuffer* pb_)
void VNCServerST::setScreenLayout(const ScreenSet& layout)
{
if (!pb)
- throw Exception("setScreenLayout: new screen layout without a PixelBuffer");
+ throw std::logic_error("setScreenLayout: new screen layout without a PixelBuffer");
if (!layout.validate(pb->width(), pb->height()))
- throw Exception("setScreenLayout: invalid screen layout");
+ throw std::invalid_argument("setScreenLayout: invalid screen layout");
screenLayout = layout;
@@ -378,7 +377,7 @@ void VNCServerST::sendClipboardData(const char* data)
std::list<VNCSConnectionST*>::iterator ci;
if (strchr(data, '\r') != nullptr)
- throw Exception("Invalid carriage return in clipboard data");
+ throw std::invalid_argument("Invalid carriage return in clipboard data");
for (ci = clipboardRequestors.begin();
ci != clipboardRequestors.end(); ++ci)
@@ -566,7 +565,7 @@ unsigned int VNCServerST::setDesktopSize(VNCSConnectionST* requester,
// Sanity check
if (screenLayout != layout)
- throw Exception("Desktop configured a different screen layout than requested");
+ throw std::runtime_error("Desktop configured a different screen layout than requested");
// Notify other clients
for (ci = clients.begin(); ci != clients.end(); ++ci) {
@@ -727,7 +726,7 @@ void VNCServerST::startDesktop()
slog.debug("starting desktop");
desktop->start();
if (!pb)
- throw Exception("SDesktop::start() did not set a valid PixelBuffer");
+ throw std::logic_error("SDesktop::start() did not set a valid PixelBuffer");
desktopStarted = true;
// The tracker might have accumulated changes whilst we were
// stopped, so flush those out
diff --git a/common/rfb/obfuscate.cxx b/common/rfb/obfuscate.cxx
index 2afc1512..a88d2822 100644
--- a/common/rfb/obfuscate.cxx
+++ b/common/rfb/obfuscate.cxx
@@ -28,11 +28,12 @@
#include <assert.h>
#include <string.h>
+#include <stdexcept>
+
extern "C" {
#include <rfb/d3des.h>
}
-#include <rdr/Exception.h>
#include <rfb/obfuscate.h>
static unsigned char d3desObfuscationKey[] = {23,82,107,6,35,78,88,7};
@@ -57,7 +58,7 @@ std::string rfb::deobfuscate(const uint8_t *data, size_t len)
char buf[9];
if (len != 8)
- throw rdr::Exception("bad obfuscated password length");
+ throw std::invalid_argument("bad obfuscated password length");
assert(data != nullptr);