aboutsummaryrefslogtreecommitdiffstats
path: root/common/rfb
diff options
context:
space:
mode:
Diffstat (limited to 'common/rfb')
-rw-r--r--common/rfb/CConnection.cxx20
-rw-r--r--common/rfb/CConnection.h2
-rw-r--r--common/rfb/CMsgReader.cxx26
-rw-r--r--common/rfb/CSecurityDH.cxx4
-rw-r--r--common/rfb/CSecurityRSAAES.cxx16
-rw-r--r--common/rfb/CSecurityTLS.cxx62
-rw-r--r--common/rfb/CSecurityVeNCrypt.cxx12
-rw-r--r--common/rfb/DecodeManager.cxx4
-rw-r--r--common/rfb/Exception.h16
-rw-r--r--common/rfb/HextileDecoder.cxx2
-rw-r--r--common/rfb/JpegDecompressor.cxx2
-rw-r--r--common/rfb/PixelFormat.cxx2
-rw-r--r--common/rfb/RREDecoder.cxx2
-rw-r--r--common/rfb/SConnection.cxx14
-rw-r--r--common/rfb/SConnection.h13
-rw-r--r--common/rfb/SMsgReader.cxx16
-rw-r--r--common/rfb/SSecurity.h17
-rw-r--r--common/rfb/SSecurityPlain.cxx6
-rw-r--r--common/rfb/SSecurityRSAAES.cxx20
-rw-r--r--common/rfb/SSecurityTLS.cxx28
-rw-r--r--common/rfb/SSecurityVeNCrypt.cxx8
-rw-r--r--common/rfb/SSecurityVncAuth.cxx2
-rw-r--r--common/rfb/TightDecoder.cxx10
-rw-r--r--common/rfb/VNCSConnectionST.cxx4
-rw-r--r--common/rfb/ZRLEDecoder.cxx6
25 files changed, 158 insertions, 156 deletions
diff --git a/common/rfb/CConnection.cxx b/common/rfb/CConnection.cxx
index 8a718b5f..a4d6d173 100644
--- a/common/rfb/CConnection.cxx
+++ b/common/rfb/CConnection.cxx
@@ -172,7 +172,7 @@ bool CConnection::processVersionMsg()
if (sscanf(verStr, "RFB %03d.%03d\n",
&majorVersion, &minorVersion) != 2) {
state_ = RFBSTATE_INVALID;
- throw ProtocolException("reading version failed: not an RFB server?");
+ throw protocol_error("reading version failed: not an RFB server?");
}
server.setVersion(majorVersion, minorVersion);
@@ -185,10 +185,10 @@ bool CConnection::processVersionMsg()
vlog.error("Server gave unsupported RFB protocol version %d.%d",
server.majorVersion, server.minorVersion);
state_ = RFBSTATE_INVALID;
- throw ProtocolException(format("Server gave unsupported RFB "
- "protocol version %d.%d",
- server.majorVersion,
- server.minorVersion));
+ throw protocol_error(format("Server gave unsupported RFB protocol "
+ "version %d.%d",
+ server.majorVersion,
+ server.minorVersion));
} else if (server.beforeVersion(3,7)) {
server.setVersion(3,3);
} else if (server.afterVersion(3,8)) {
@@ -235,7 +235,7 @@ bool CConnection::processSecurityTypesMsg()
secType = secTypeInvalid;
} else {
vlog.error("Unknown 3.3 security type %d", secType);
- throw ProtocolException("Unknown 3.3 security type");
+ throw protocol_error("Unknown 3.3 security type");
}
} else {
@@ -285,7 +285,7 @@ bool CConnection::processSecurityTypesMsg()
if (secType == secTypeInvalid) {
state_ = RFBSTATE_INVALID;
vlog.error("No matching security types");
- throw ProtocolException("No matching security types");
+ throw protocol_error("No matching security types");
}
state_ = RFBSTATE_SECURITY;
@@ -329,12 +329,12 @@ bool CConnection::processSecurityResultMsg()
vlog.debug("auth failed - too many tries");
break;
default:
- throw ProtocolException("Unknown security result from server");
+ throw protocol_error("Unknown security result from server");
}
if (server.beforeVersion(3,8)) {
state_ = RFBSTATE_INVALID;
- throw AuthFailureException("Authentication failed");
+ throw auth_error("Authentication failed");
}
state_ = RFBSTATE_SECURITY_REASON;
@@ -360,7 +360,7 @@ bool CConnection::processSecurityReasonMsg()
reason[len] = '\0';
state_ = RFBSTATE_INVALID;
- throw AuthFailureException(reason.data());
+ throw auth_error(reason.data());
}
bool CConnection::processInitMsg()
diff --git a/common/rfb/CConnection.h b/common/rfb/CConnection.h
index 3f277d71..9101bf26 100644
--- a/common/rfb/CConnection.h
+++ b/common/rfb/CConnection.h
@@ -273,7 +273,7 @@ namespace rfb {
bool processSecurityResultMsg();
bool processSecurityReasonMsg();
bool processInitMsg();
- void throwAuthFailureException();
+ void throwAuthError();
void securityCompleted();
void requestNewUpdate();
diff --git a/common/rfb/CMsgReader.cxx b/common/rfb/CMsgReader.cxx
index 17c92227..3025959f 100644
--- a/common/rfb/CMsgReader.cxx
+++ b/common/rfb/CMsgReader.cxx
@@ -119,7 +119,7 @@ bool CMsgReader::readMsg()
ret = readEndOfContinuousUpdates();
break;
default:
- throw ProtocolException(format("Unknown message type %d", currentMsgType));
+ throw protocol_error(format("Unknown message type %d", currentMsgType));
}
if (ret)
@@ -301,7 +301,7 @@ bool CMsgReader::readExtendedClipboard(int32_t len)
return false;
if (len < 4)
- throw ProtocolException("Invalid extended clipboard message");
+ throw protocol_error("Invalid extended clipboard message");
if (len > maxCutText) {
vlog.error("Extended clipboard message too long (%d bytes) - ignoring", len);
is->skip(len);
@@ -323,7 +323,7 @@ bool CMsgReader::readExtendedClipboard(int32_t len)
}
if (len < (int32_t)(4 + 4*num))
- throw ProtocolException("Invalid extended clipboard message");
+ throw protocol_error("Invalid extended clipboard message");
num = 0;
for (i = 0;i < 16;i++) {
@@ -348,7 +348,7 @@ bool CMsgReader::readExtendedClipboard(int32_t len)
continue;
if (!zis.hasData(4))
- throw ProtocolException("Extended clipboard decode error");
+ throw protocol_error("Extended clipboard decode error");
lengths[num] = zis.readU32();
@@ -361,7 +361,7 @@ bool CMsgReader::readExtendedClipboard(int32_t len)
size_t chunk;
if (!zis.hasData(1))
- throw ProtocolException("Extended clipboard decode error");
+ throw protocol_error("Extended clipboard decode error");
chunk = zis.avail();
if (chunk > lengths[num])
@@ -377,7 +377,7 @@ bool CMsgReader::readExtendedClipboard(int32_t len)
}
if (!zis.hasData(lengths[num]))
- throw ProtocolException("Extended clipboard decode error");
+ throw protocol_error("Extended clipboard decode error");
buffers[num] = new uint8_t[lengths[num]];
zis.readBytes(buffers[num], lengths[num]);
@@ -407,7 +407,7 @@ bool CMsgReader::readExtendedClipboard(int32_t len)
handler->handleClipboardNotify(flags);
break;
default:
- throw ProtocolException("Invalid extended clipboard action");
+ throw protocol_error("Invalid extended clipboard action");
}
}
@@ -473,7 +473,7 @@ bool CMsgReader::readRect(const Rect& r, int encoding)
vlog.error("Rect too big: %dx%d at %d,%d exceeds %dx%d",
r.width(), r.height(), r.tl.x, r.tl.y,
handler->server.width(), handler->server.height());
- throw ProtocolException("Rect too big");
+ throw protocol_error("Rect too big");
}
if (r.is_empty())
@@ -485,7 +485,7 @@ bool CMsgReader::readRect(const Rect& r, int encoding)
bool CMsgReader::readSetXCursor(int width, int height, const Point& hotspot)
{
if (width > maxCursorSize || height > maxCursorSize)
- throw ProtocolException("Too big cursor");
+ throw protocol_error("Too big cursor");
std::vector<uint8_t> rgba(width*height*4);
@@ -549,7 +549,7 @@ bool CMsgReader::readSetXCursor(int width, int height, const Point& hotspot)
bool CMsgReader::readSetCursor(int width, int height, const Point& hotspot)
{
if (width > maxCursorSize || height > maxCursorSize)
- throw ProtocolException("Too big cursor");
+ throw protocol_error("Too big cursor");
int data_len = width * height * (handler->server.pf().bpp/8);
int mask_len = ((width+7)/8) * height;
@@ -595,7 +595,7 @@ bool CMsgReader::readSetCursor(int width, int height, const Point& hotspot)
bool CMsgReader::readSetCursorWithAlpha(int width, int height, const Point& hotspot)
{
if (width > maxCursorSize || height > maxCursorSize)
- throw ProtocolException("Too big cursor");
+ throw protocol_error("Too big cursor");
const PixelFormat rgbaPF(32, 32, false, true, 255, 255, 255, 16, 8, 0);
ManagedPixelBuffer pb(rgbaPF, width, height);
@@ -656,7 +656,7 @@ bool CMsgReader::readSetCursorWithAlpha(int width, int height, const Point& hots
bool CMsgReader::readSetVMwareCursor(int width, int height, const Point& hotspot)
{
if (width > maxCursorSize || height > maxCursorSize)
- throw ProtocolException("Too big cursor");
+ throw protocol_error("Too big cursor");
uint8_t type;
@@ -750,7 +750,7 @@ bool CMsgReader::readSetVMwareCursor(int width, int height, const Point& hotspot
handler->setCursor(width, height, hotspot, data.data());
} else {
- throw ProtocolException("Unknown cursor type");
+ throw protocol_error("Unknown cursor type");
}
return true;
diff --git a/common/rfb/CSecurityDH.cxx b/common/rfb/CSecurityDH.cxx
index ca110cb2..d8308cbf 100644
--- a/common/rfb/CSecurityDH.cxx
+++ b/common/rfb/CSecurityDH.cxx
@@ -86,9 +86,9 @@ bool CSecurityDH::readKey()
uint16_t gen = is->readU16();
keyLength = is->readU16();
if (keyLength < MinKeyLength)
- throw ProtocolException("DH key is too short");
+ throw protocol_error("DH key is too short");
if (keyLength > MaxKeyLength)
- throw ProtocolException("DH key is too long");
+ throw protocol_error("DH key is too long");
if (!is->hasDataOrRestore(keyLength * 2))
return false;
is->clearRestorePoint();
diff --git a/common/rfb/CSecurityRSAAES.cxx b/common/rfb/CSecurityRSAAES.cxx
index 11c392d5..96fd20cd 100644
--- a/common/rfb/CSecurityRSAAES.cxx
+++ b/common/rfb/CSecurityRSAAES.cxx
@@ -174,9 +174,9 @@ bool CSecurityRSAAES::readPublicKey()
is->setRestorePoint();
serverKeyLength = is->readU32();
if (serverKeyLength < MinKeyLength)
- throw ProtocolException("server key is too short");
+ throw protocol_error("server key is too short");
if (serverKeyLength > MaxKeyLength)
- throw ProtocolException("server key is too long");
+ throw protocol_error("server key is too long");
size_t size = (serverKeyLength + 7) / 8;
if (!is->hasDataOrRestore(size * 2))
return false;
@@ -189,7 +189,7 @@ bool CSecurityRSAAES::readPublicKey()
nettle_mpz_set_str_256_u(serverKey.n, size, serverKeyN);
nettle_mpz_set_str_256_u(serverKey.e, size, serverKeyE);
if (!rsa_public_key_prepare(&serverKey))
- throw ProtocolException("server key is invalid");
+ throw protocol_error("server key is invalid");
return true;
}
@@ -215,7 +215,7 @@ void CSecurityRSAAES::verifyServer()
"Please verify that the information is correct and press \"Yes\". "
"Otherwise press \"No\"", f[0], f[1], f[2], f[3], f[4], f[5], f[6], f[7]);
if (!cc->showMsgBox(MsgBoxFlags::M_YESNO, title, text.c_str()))
- throw AuthCancelledException();
+ throw auth_cancelled();
}
void CSecurityRSAAES::writeRandom()
@@ -255,7 +255,7 @@ bool CSecurityRSAAES::readRandom()
is->setRestorePoint();
size_t size = is->readU16();
if (size != clientKey.size)
- throw ProtocolException("client key length doesn't match");
+ throw protocol_error("client key length doesn't match");
if (!is->hasDataOrRestore(size))
return false;
is->clearRestorePoint();
@@ -268,7 +268,7 @@ bool CSecurityRSAAES::readRandom()
if (!rsa_decrypt(&clientKey, &randomSize, serverRandom, x) ||
randomSize != (size_t)keySize / 8) {
mpz_clear(x);
- throw ProtocolException("failed to decrypt server random");
+ throw protocol_error("failed to decrypt server random");
}
mpz_clear(x);
return true;
@@ -397,7 +397,7 @@ bool CSecurityRSAAES::readHash()
sha256_digest(&ctx, hashSize, realHash);
}
if (memcmp(hash, realHash, hashSize) != 0)
- throw ProtocolException("hash doesn't match");
+ throw protocol_error("hash doesn't match");
return true;
}
@@ -427,7 +427,7 @@ bool CSecurityRSAAES::readSubtype()
return false;
subtype = rais->readU8();
if (subtype != secTypeRA2UserPass && subtype != secTypeRA2Pass)
- throw ProtocolException("unknown RSA-AES subtype");
+ throw protocol_error("unknown RSA-AES subtype");
return true;
}
diff --git a/common/rfb/CSecurityTLS.cxx b/common/rfb/CSecurityTLS.cxx
index fc1cde8e..3761ca30 100644
--- a/common/rfb/CSecurityTLS.cxx
+++ b/common/rfb/CSecurityTLS.cxx
@@ -80,7 +80,7 @@ CSecurityTLS::CSecurityTLS(CConnection* cc_, bool _anon)
{
int err = gnutls_global_init();
if (err != GNUTLS_E_SUCCESS)
- throw rdr::TLSException("gnutls_global_init()", err);
+ throw rdr::tls_error("gnutls_global_init()", err);
}
void CSecurityTLS::shutdown()
@@ -146,15 +146,15 @@ bool CSecurityTLS::processMsg()
return false;
if (is->readU8() == 0)
- throw ProtocolException("Server failed to initialize TLS session");
+ throw protocol_error("Server failed to initialize TLS session");
ret = gnutls_init(&session, GNUTLS_CLIENT);
if (ret != GNUTLS_E_SUCCESS)
- throw rdr::TLSException("gnutls_init()", ret);
+ throw rdr::tls_error("gnutls_init()", ret);
ret = gnutls_set_default_priority(session);
if (ret != GNUTLS_E_SUCCESS)
- throw rdr::TLSException("gnutls_set_default_priority()", ret);
+ throw rdr::tls_error("gnutls_set_default_priority()", ret);
setParam();
@@ -177,7 +177,7 @@ bool CSecurityTLS::processMsg()
vlog.error("TLS Handshake failed: %s\n", gnutls_strerror (err));
shutdown();
- throw rdr::TLSException("TLS Handshake failed", err);
+ throw rdr::tls_error("TLS Handshake failed", err);
}
vlog.debug("TLS handshake completed with %s",
@@ -215,7 +215,7 @@ void CSecurityTLS::setParam()
if (ret != GNUTLS_E_SUCCESS) {
if (ret == GNUTLS_E_INVALID_REQUEST)
vlog.error("GnuTLS priority syntax error at: %s", err);
- throw rdr::TLSException("gnutls_set_priority_direct()", ret);
+ throw rdr::tls_error("gnutls_set_priority_direct()", ret);
}
} else if (anon) {
const char *err;
@@ -227,7 +227,7 @@ void CSecurityTLS::setParam()
if (ret != GNUTLS_E_SUCCESS) {
if (ret == GNUTLS_E_INVALID_REQUEST)
vlog.error("GnuTLS priority syntax error at: %s", err);
- throw rdr::TLSException("gnutls_set_default_priority_append()", ret);
+ throw rdr::tls_error("gnutls_set_default_priority_append()", ret);
}
#else
// We don't know what the system default priority is, so we guess
@@ -248,7 +248,7 @@ void CSecurityTLS::setParam()
if (ret != GNUTLS_E_SUCCESS) {
if (ret == GNUTLS_E_INVALID_REQUEST)
vlog.error("GnuTLS priority syntax error at: %s", err);
- throw rdr::TLSException("gnutls_set_priority_direct()", ret);
+ throw rdr::tls_error("gnutls_set_priority_direct()", ret);
}
#endif
}
@@ -256,17 +256,17 @@ void CSecurityTLS::setParam()
if (anon) {
ret = gnutls_anon_allocate_client_credentials(&anon_cred);
if (ret != GNUTLS_E_SUCCESS)
- throw rdr::TLSException("gnutls_anon_allocate_client_credentials()", ret);
+ throw rdr::tls_error("gnutls_anon_allocate_client_credentials()", ret);
ret = gnutls_credentials_set(session, GNUTLS_CRD_ANON, anon_cred);
if (ret != GNUTLS_E_SUCCESS)
- throw rdr::TLSException("gnutls_credentials_set()", ret);
+ throw rdr::tls_error("gnutls_credentials_set()", ret);
vlog.debug("Anonymous session has been set");
} else {
ret = gnutls_certificate_allocate_credentials(&cert_cred);
if (ret != GNUTLS_E_SUCCESS)
- throw rdr::TLSException("gnutls_certificate_allocate_credentials()", ret);
+ throw rdr::tls_error("gnutls_certificate_allocate_credentials()", ret);
if (gnutls_certificate_set_x509_system_trust(cert_cred) < 1)
vlog.error("Could not load system certificate trust store");
@@ -279,7 +279,7 @@ void CSecurityTLS::setParam()
ret = gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, cert_cred);
if (ret != GNUTLS_E_SUCCESS)
- throw rdr::TLSException("gnutls_credentials_set()", ret);
+ throw rdr::tls_error("gnutls_credentials_set()", ret);
if (gnutls_server_name_set(session, GNUTLS_NAME_DNS,
client->getServerName(),
@@ -312,12 +312,12 @@ void CSecurityTLS::checkSession()
return;
if (gnutls_certificate_type_get(session) != GNUTLS_CRT_X509)
- throw ProtocolException("unsupported certificate type");
+ throw protocol_error("unsupported certificate type");
err = gnutls_certificate_verify_peers2(session, &status);
if (err != 0) {
vlog.error("server certificate verification failed: %s", gnutls_strerror(err));
- throw rdr::TLSException("server certificate verification()", err);
+ throw rdr::tls_error("server certificate verification()", err);
}
if (status != 0) {
@@ -334,13 +334,13 @@ void CSecurityTLS::checkSession()
&status_str,
0);
if (err != GNUTLS_E_SUCCESS)
- throw rdr::TLSException("Failed to get certificate error description", err);
+ throw rdr::tls_error("Failed to get certificate error description", err);
error = (const char*)status_str.data;
gnutls_free(status_str.data);
- throw ProtocolException(format("Invalid server certificate: %s",
+ throw protocol_error(format("Invalid server certificate: %s",
error.c_str()));
}
@@ -349,7 +349,7 @@ void CSecurityTLS::checkSession()
&status_str,
0);
if (err != GNUTLS_E_SUCCESS)
- throw rdr::TLSException("Failed to get certificate error description", err);
+ throw rdr::tls_error("Failed to get certificate error description", err);
vlog.info("Server certificate errors: %s", status_str.data);
@@ -360,7 +360,7 @@ void CSecurityTLS::checkSession()
cert_list = gnutls_certificate_get_peers(session, &cert_list_size);
if (!cert_list_size)
- throw ProtocolException("empty certificate chain");
+ throw protocol_error("empty certificate chain");
/* Process only server's certificate, not issuer's certificate */
gnutls_x509_crt_t crt;
@@ -368,7 +368,7 @@ void CSecurityTLS::checkSession()
err = gnutls_x509_crt_import(crt, &cert_list[0], GNUTLS_X509_FMT_DER);
if (err != GNUTLS_E_SUCCESS)
- throw rdr::TLSException("Failed to decode server certificate", err);
+ throw rdr::tls_error("Failed to decode server certificate", err);
if (gnutls_x509_crt_check_hostname(crt, client->getServerName()) == 0) {
vlog.info("Server certificate doesn't match given server name");
@@ -407,12 +407,12 @@ void CSecurityTLS::checkSession()
if ((known != GNUTLS_E_NO_CERTIFICATE_FOUND) &&
(known != GNUTLS_E_CERTIFICATE_KEY_MISMATCH)) {
- throw rdr::TLSException("Could not load known hosts database", known);
+ throw rdr::tls_error("Could not load known hosts database", known);
}
err = gnutls_x509_crt_print(crt, GNUTLS_CRT_PRINT_ONELINE, &info);
if (err != GNUTLS_E_SUCCESS)
- throw rdr::TLSException("Could not find certificate to display", err);
+ throw rdr::tls_error("Could not find certificate to display", err);
len = strlen((char*)info.data);
for (size_t i = 0; i < len - 1; i++) {
@@ -444,7 +444,7 @@ void CSecurityTLS::checkSession()
if (!cc->showMsgBox(MsgBoxFlags::M_YESNO,
"Unknown certificate issuer",
text.c_str()))
- throw AuthCancelledException();
+ throw auth_cancelled();
status &= ~(GNUTLS_CERT_INVALID |
GNUTLS_CERT_SIGNER_NOT_FOUND |
@@ -464,7 +464,7 @@ void CSecurityTLS::checkSession()
if (!cc->showMsgBox(MsgBoxFlags::M_YESNO,
"Certificate is not yet valid",
text.c_str()))
- throw AuthCancelledException();
+ throw auth_cancelled();
status &= ~GNUTLS_CERT_NOT_ACTIVATED;
}
@@ -483,7 +483,7 @@ void CSecurityTLS::checkSession()
if (!cc->showMsgBox(MsgBoxFlags::M_YESNO,
"Expired certificate",
text.c_str()))
- throw AuthCancelledException();
+ throw auth_cancelled();
status &= ~GNUTLS_CERT_EXPIRED;
}
@@ -502,7 +502,7 @@ void CSecurityTLS::checkSession()
if (!cc->showMsgBox(MsgBoxFlags::M_YESNO,
"Insecure certificate algorithm",
text.c_str()))
- throw AuthCancelledException();
+ throw auth_cancelled();
status &= ~GNUTLS_CERT_INSECURE_ALGORITHM;
}
@@ -527,7 +527,7 @@ void CSecurityTLS::checkSession()
if (!cc->showMsgBox(MsgBoxFlags::M_YESNO,
"Certificate hostname mismatch",
text.c_str()))
- throw AuthCancelledException();
+ throw auth_cancelled();
}
} else if (known == GNUTLS_E_CERTIFICATE_KEY_MISMATCH) {
std::string text;
@@ -553,7 +553,7 @@ void CSecurityTLS::checkSession()
if (!cc->showMsgBox(MsgBoxFlags::M_YESNO,
"Unexpected server certificate",
text.c_str()))
- throw AuthCancelledException();
+ throw auth_cancelled();
status &= ~(GNUTLS_CERT_INVALID |
GNUTLS_CERT_SIGNER_NOT_FOUND |
@@ -576,7 +576,7 @@ void CSecurityTLS::checkSession()
if (!cc->showMsgBox(MsgBoxFlags::M_YESNO,
"Unexpected server certificate",
text.c_str()))
- throw AuthCancelledException();
+ throw auth_cancelled();
status &= ~GNUTLS_CERT_NOT_ACTIVATED;
}
@@ -597,7 +597,7 @@ void CSecurityTLS::checkSession()
if (!cc->showMsgBox(MsgBoxFlags::M_YESNO,
"Unexpected server certificate",
text.c_str()))
- throw AuthCancelledException();
+ throw auth_cancelled();
status &= ~GNUTLS_CERT_EXPIRED;
}
@@ -618,7 +618,7 @@ void CSecurityTLS::checkSession()
if (!cc->showMsgBox(MsgBoxFlags::M_YESNO,
"Unexpected server certificate",
text.c_str()))
- throw AuthCancelledException();
+ throw auth_cancelled();
status &= ~GNUTLS_CERT_INSECURE_ALGORITHM;
}
@@ -645,7 +645,7 @@ void CSecurityTLS::checkSession()
if (!cc->showMsgBox(MsgBoxFlags::M_YESNO,
"Unexpected server certificate",
text.c_str()))
- throw AuthCancelledException();
+ throw auth_cancelled();
}
}
diff --git a/common/rfb/CSecurityVeNCrypt.cxx b/common/rfb/CSecurityVeNCrypt.cxx
index 606fd96f..1b6ecf22 100644
--- a/common/rfb/CSecurityVeNCrypt.cxx
+++ b/common/rfb/CSecurityVeNCrypt.cxx
@@ -105,7 +105,7 @@ bool CSecurityVeNCrypt::processMsg()
os->writeU8(0);
os->writeU8(0);
os->flush();
- throw ProtocolException("The server reported an unsupported VeNCrypt version");
+ throw protocol_error("The server reported an unsupported VeNCrypt version");
}
haveSentVersion = true;
@@ -117,8 +117,8 @@ bool CSecurityVeNCrypt::processMsg()
return false;
if (is->readU8())
- throw ProtocolException("The server reported it could not "
- "support the VeNCrypt version");
+ throw protocol_error("The server reported it could not "
+ "support the VeNCrypt version");
haveAgreedVersion = true;
}
@@ -131,7 +131,7 @@ bool CSecurityVeNCrypt::processMsg()
nAvailableTypes = is->readU8();
if (!nAvailableTypes)
- throw ProtocolException("The server reported no VeNCrypt sub-types");
+ throw protocol_error("The server reported no VeNCrypt sub-types");
availableTypes = new uint32_t[nAvailableTypes];
haveNumberOfTypes = true;
@@ -172,7 +172,7 @@ bool CSecurityVeNCrypt::processMsg()
/* Set up the stack according to the chosen type: */
if (chosenType == secTypeInvalid || chosenType == secTypeVeNCrypt)
- throw ProtocolException("No valid VeNCrypt sub-type");
+ throw protocol_error("No valid VeNCrypt sub-type");
vlog.info("Choosing security type %s (%d)", secTypeName(chosenType),
chosenType);
@@ -191,7 +191,7 @@ bool CSecurityVeNCrypt::processMsg()
* happen, since if the server supports 0 sub-types, it doesn't support
* this security type
*/
- throw ProtocolException("The server reported 0 VeNCrypt sub-types");
+ throw protocol_error("The server reported 0 VeNCrypt sub-types");
}
return csecurity->processMsg();
diff --git a/common/rfb/DecodeManager.cxx b/common/rfb/DecodeManager.cxx
index 0475d62d..09118f36 100644
--- a/common/rfb/DecodeManager.cxx
+++ b/common/rfb/DecodeManager.cxx
@@ -114,14 +114,14 @@ bool DecodeManager::decodeRect(const Rect& r, int encoding,
if (!Decoder::supported(encoding)) {
vlog.error("Unknown encoding %d", encoding);
- throw ProtocolException("Unknown encoding");
+ throw protocol_error("Unknown encoding");
}
if (!decoders[encoding]) {
decoders[encoding] = Decoder::createDecoder(encoding);
if (!decoders[encoding]) {
vlog.error("Unknown encoding %d", encoding);
- throw ProtocolException("Unknown encoding");
+ throw protocol_error("Unknown encoding");
}
}
diff --git a/common/rfb/Exception.h b/common/rfb/Exception.h
index 3b81b4a7..0e74209c 100644
--- a/common/rfb/Exception.h
+++ b/common/rfb/Exception.h
@@ -22,21 +22,21 @@
#include <stdexcept>
namespace rfb {
- class ProtocolException : public std::runtime_error {
+ class protocol_error : public std::runtime_error {
public:
- ProtocolException(const char* what_arg) : std::runtime_error(what_arg) {}
- ProtocolException(const std::string& what_arg) : std::runtime_error(what_arg) {}
+ protocol_error(const char* what_arg) : std::runtime_error(what_arg) {}
+ protocol_error(const std::string& what_arg) : std::runtime_error(what_arg) {}
};
- class AuthFailureException : public std::runtime_error {
+ class auth_error : public std::runtime_error {
public:
- AuthFailureException(const char* reason) : std::runtime_error(reason) {}
- AuthFailureException(std::string& reason) : std::runtime_error(reason) {}
+ auth_error(const char* reason) : std::runtime_error(reason) {}
+ auth_error(std::string& reason) : std::runtime_error(reason) {}
};
- class AuthCancelledException : public std::runtime_error {
+ class auth_cancelled : public std::runtime_error {
public:
- AuthCancelledException()
+ auth_cancelled()
: std::runtime_error("Authentication cancelled") {}
};
}
diff --git a/common/rfb/HextileDecoder.cxx b/common/rfb/HextileDecoder.cxx
index d440b1af..35ec7928 100644
--- a/common/rfb/HextileDecoder.cxx
+++ b/common/rfb/HextileDecoder.cxx
@@ -189,7 +189,7 @@ void HextileDecoder::hextileDecode(const Rect& r, rdr::InStream* is,
int w = ((wh >> 4) & 15) + 1;
int h = (wh & 15) + 1;
if (x + w > 16 || y + h > 16) {
- throw ProtocolException("HEXTILE_DECODE: Hextile out of bounds");
+ throw protocol_error("HEXTILE_DECODE: Hextile out of bounds");
}
ptr = buf + y * t.width() + x;
int rowAdd = t.width() - w;
diff --git a/common/rfb/JpegDecompressor.cxx b/common/rfb/JpegDecompressor.cxx
index 60c215fc..10c9e49c 100644
--- a/common/rfb/JpegDecompressor.cxx
+++ b/common/rfb/JpegDecompressor.cxx
@@ -217,7 +217,7 @@ void JpegDecompressor::decompress(const uint8_t *jpegBuf,
jpeg_abort_decompress(dinfo);
if (dstBufIsTemp && dstBuf) delete[] dstBuf;
if (rowPointer) delete[] rowPointer;
- throw ProtocolException("Tight Decoding: Wrong JPEG data received.\n");
+ throw protocol_error("Tight Decoding: Wrong JPEG data received.\n");
}
while (dinfo->output_scanline < dinfo->output_height) {
diff --git a/common/rfb/PixelFormat.cxx b/common/rfb/PixelFormat.cxx
index a538deb7..e312b3c9 100644
--- a/common/rfb/PixelFormat.cxx
+++ b/common/rfb/PixelFormat.cxx
@@ -180,7 +180,7 @@ void PixelFormat::read(rdr::InStream* is)
}
if (!isSane())
- throw ProtocolException("invalid pixel format");
+ throw protocol_error("invalid pixel format");
updateState();
}
diff --git a/common/rfb/RREDecoder.cxx b/common/rfb/RREDecoder.cxx
index 4f2db071..53ddc2da 100644
--- a/common/rfb/RREDecoder.cxx
+++ b/common/rfb/RREDecoder.cxx
@@ -107,7 +107,7 @@ void RREDecoder::rreDecode(const Rect& r, rdr::InStream* is,
int h = is->readU16();
if (((x+w) > r.width()) || ((y+h) > r.height()))
- throw ProtocolException("RRE decode error");
+ throw protocol_error("RRE decode error");
pb->fillRect(pf, Rect(r.tl.x+x, r.tl.y+y, r.tl.x+x+w, r.tl.y+y+h), &pix);
}
diff --git a/common/rfb/SConnection.cxx b/common/rfb/SConnection.cxx
index 6e58b3b4..0cde5bc6 100644
--- a/common/rfb/SConnection.cxx
+++ b/common/rfb/SConnection.cxx
@@ -123,7 +123,7 @@ bool SConnection::processVersionMsg()
if (sscanf(verStr, "RFB %03d.%03d\n",
&majorVersion, &minorVersion) != 2) {
state_ = RFBSTATE_INVALID;
- throw ProtocolException("reading version failed: not an RFB client?");
+ throw protocol_error("reading version failed: not an RFB client?");
}
client.setVersion(majorVersion, minorVersion);
@@ -215,7 +215,7 @@ void SConnection::processSecurityType(int secType)
secTypes = security.GetEnabledSecTypes();
if (std::find(secTypes.begin(), secTypes.end(),
secType) == secTypes.end())
- throw ProtocolException("Requested security type not available");
+ throw protocol_error("Requested security type not available");
vlog.info("Client requests security type %s(%d)",
secTypeName(secType),secType);
@@ -234,8 +234,8 @@ bool SConnection::processSecurityMsg()
try {
if (!ssecurity->processMsg())
return false;
- } catch (AuthFailureException& e) {
- vlog.error("AuthFailureException: %s", e.what());
+ } catch (auth_error& e) {
+ vlog.error("Authentication error: %s", e.what());
state_ = RFBSTATE_SECURITY_FAILURE;
// Introduce a slight delay of the authentication failure response
// to make it difficult to brute force a password
@@ -320,7 +320,7 @@ void SConnection::failConnection(const char* message)
}
state_ = RFBSTATE_INVALID;
- throw ProtocolException(message);
+ throw protocol_error(message);
}
void SConnection::failConnection(const std::string& message)
@@ -474,9 +474,9 @@ void SConnection::approveConnection(bool accept, const char* reason)
} else {
state_ = RFBSTATE_INVALID;
if (reason)
- throw AuthFailureException(reason);
+ throw auth_error(reason);
else
- throw AuthFailureException("Connection rejected");
+ throw auth_error("Connection rejected");
}
}
diff --git a/common/rfb/SConnection.h b/common/rfb/SConnection.h
index 886972af..ccffa74f 100644
--- a/common/rfb/SConnection.h
+++ b/common/rfb/SConnection.h
@@ -68,12 +68,13 @@ namespace rfb {
// data is available.
bool processMsg();
- // approveConnection() is called to either accept or reject the connection.
- // If accept is false, the reason string gives the reason for the
- // rejection. It can either be called directly from queryConnection() or
- // later, after queryConnection() has returned. It can only be called when
- // in state RFBSTATE_QUERYING. On rejection, an AuthFailureException is
- // thrown, so this must be handled appropriately by the caller.
+ // approveConnection() is called to either accept or reject the
+ // connection. If accept is false, the reason string gives the
+ // reason for the rejection. It can either be called directly from
+ // queryConnection() or later, after queryConnection() has returned.
+ // It can only be called when in state RFBSTATE_QUERYING. On
+ // rejection, an auth_error is thrown, so this must be handled
+ // appropriately by the caller.
void approveConnection(bool accept, const char* reason=nullptr);
diff --git a/common/rfb/SMsgReader.cxx b/common/rfb/SMsgReader.cxx
index ee37370e..fcc0a63c 100644
--- a/common/rfb/SMsgReader.cxx
+++ b/common/rfb/SMsgReader.cxx
@@ -107,7 +107,7 @@ bool SMsgReader::readMsg()
break;
default:
vlog.error("unknown message type %d", currentMsgType);
- throw ProtocolException("unknown message type");
+ throw protocol_error("unknown message type");
}
if (ret)
@@ -334,7 +334,7 @@ bool SMsgReader::readExtendedClipboard(int32_t len)
return false;
if (len < 4)
- throw ProtocolException("Invalid extended clipboard message");
+ throw protocol_error("Invalid extended clipboard message");
if (len > maxCutText) {
vlog.error("Extended clipboard message too long (%d bytes) - ignoring", len);
is->skip(len);
@@ -356,7 +356,7 @@ bool SMsgReader::readExtendedClipboard(int32_t len)
}
if (len < (int32_t)(4 + 4*num))
- throw ProtocolException("Invalid extended clipboard message");
+ throw protocol_error("Invalid extended clipboard message");
num = 0;
for (i = 0;i < 16;i++) {
@@ -381,7 +381,7 @@ bool SMsgReader::readExtendedClipboard(int32_t len)
continue;
if (!zis.hasData(4))
- throw ProtocolException("Extended clipboard decode error");
+ throw protocol_error("Extended clipboard decode error");
lengths[num] = zis.readU32();
@@ -394,7 +394,7 @@ bool SMsgReader::readExtendedClipboard(int32_t len)
size_t chunk;
if (!zis.hasData(1))
- throw ProtocolException("Extended clipboard decode error");
+ throw protocol_error("Extended clipboard decode error");
chunk = zis.avail();
if (chunk > lengths[num])
@@ -410,7 +410,7 @@ bool SMsgReader::readExtendedClipboard(int32_t len)
}
if (!zis.hasData(lengths[num]))
- throw ProtocolException("Extended clipboard decode error");
+ throw protocol_error("Extended clipboard decode error");
buffers[num] = new uint8_t[lengths[num]];
zis.readBytes(buffers[num], lengths[num]);
@@ -440,7 +440,7 @@ bool SMsgReader::readExtendedClipboard(int32_t len)
handler->handleClipboardNotify(flags);
break;
default:
- throw ProtocolException("Invalid extended clipboard action");
+ throw protocol_error("Invalid extended clipboard action");
}
}
@@ -464,7 +464,7 @@ bool SMsgReader::readQEMUMessage()
ret = readQEMUKeyEvent();
break;
default:
- throw ProtocolException(format("unknown QEMU submessage type %d", subType));
+ throw protocol_error(format("unknown QEMU submessage type %d", subType));
}
if (!ret) {
diff --git a/common/rfb/SSecurity.h b/common/rfb/SSecurity.h
index 8e296c5a..0911ecd8 100644
--- a/common/rfb/SSecurity.h
+++ b/common/rfb/SSecurity.h
@@ -20,14 +20,15 @@
// derived class for a particular security type overrides the processMsg()
// method.
-// processMsg() is called first when the security type has been decided on, and
-// will keep being called whenever there is data to read from the client. It
-// should return false when it needs more data, or true when the connection has
-// been successfully authenticated. In the event of authentication failure an
-// AuthFailureException should be thrown - this will result in a "failed"
-// security result being sent to the client with the str() from the exception
-// being sent as the reason. Any other type of failure should be indicated by
-// some other kind of exception which will cause the connection to be aborted.
+// processMsg() is called first when the security type has been decided
+// on, and will keep being called whenever there is data to read from
+// the client. It should return false when it needs more data, or true
+// when the connection has been successfully authenticated. In the
+// event of authentication failure an auth_error should be thrown - this
+// will result in a "failed" security result being sent to the client
+// with the str() from the exception being sent as the reason. Any
+// other type of failure should be indicated by some other kind of
+// exception which will cause the connection to be aborted.
//
// processMsg() must never block (or at least must never block until the client
// has been authenticated) - this is to prevent denial of service attacks.
diff --git a/common/rfb/SSecurityPlain.cxx b/common/rfb/SSecurityPlain.cxx
index 1115b7ff..e62e6d60 100644
--- a/common/rfb/SSecurityPlain.cxx
+++ b/common/rfb/SSecurityPlain.cxx
@@ -95,11 +95,11 @@ bool SSecurityPlain::processMsg()
ulen = is->readU32();
if (ulen >= sizeof(username))
- throw AuthFailureException("Too long username");
+ throw auth_error("Too long username");
plen = is->readU32();
if (plen >= sizeof(password))
- throw AuthFailureException("Too long password");
+ throw auth_error("Too long password");
state = 1;
}
@@ -114,7 +114,7 @@ bool SSecurityPlain::processMsg()
username[ulen] = 0;
plen = 0;
if (!valid->validate(sc, username, password))
- throw AuthFailureException("Authentication failed");
+ throw auth_error("Authentication failed");
}
return true;
diff --git a/common/rfb/SSecurityRSAAES.cxx b/common/rfb/SSecurityRSAAES.cxx
index 45f5c293..2f26de26 100644
--- a/common/rfb/SSecurityRSAAES.cxx
+++ b/common/rfb/SSecurityRSAAES.cxx
@@ -159,7 +159,7 @@ void SSecurityRSAAES::loadPrivateKey()
{
FILE* file = fopen(keyFile, "rb");
if (!file)
- throw rdr::PosixException("failed to open key file", errno);
+ throw rdr::posix_error("failed to open key file", errno);
fseek(file, 0, SEEK_END);
size_t size = ftell(file);
if (size == 0 || size > MaxKeyFileSize) {
@@ -170,7 +170,7 @@ void SSecurityRSAAES::loadPrivateKey()
std::vector<uint8_t> data(size);
if (fread(data.data(), 1, data.size(), file) != size) {
fclose(file);
- throw rdr::PosixException("failed to read key", errno);
+ throw rdr::posix_error("failed to read key", errno);
}
fclose(file);
@@ -299,9 +299,9 @@ bool SSecurityRSAAES::readPublicKey()
is->setRestorePoint();
clientKeyLength = is->readU32();
if (clientKeyLength < MinKeyLength)
- throw ProtocolException("client key is too short");
+ throw protocol_error("client key is too short");
if (clientKeyLength > MaxKeyLength)
- throw ProtocolException("client key is too long");
+ throw protocol_error("client key is too long");
size_t size = (clientKeyLength + 7) / 8;
if (!is->hasDataOrRestore(size * 2))
return false;
@@ -314,7 +314,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 ProtocolException("client key is invalid");
+ throw protocol_error("client key is invalid");
return true;
}
@@ -363,7 +363,7 @@ bool SSecurityRSAAES::readRandom()
is->setRestorePoint();
size_t size = is->readU16();
if (size != serverKey.size)
- throw ProtocolException("server key length doesn't match");
+ throw protocol_error("server key length doesn't match");
if (!is->hasDataOrRestore(size))
return false;
is->clearRestorePoint();
@@ -376,7 +376,7 @@ bool SSecurityRSAAES::readRandom()
if (!rsa_decrypt(&serverKey, &randomSize, clientRandom, x) ||
randomSize != (size_t)keySize / 8) {
mpz_clear(x);
- throw ProtocolException("failed to decrypt client random");
+ throw protocol_error("failed to decrypt client random");
}
mpz_clear(x);
return true;
@@ -505,7 +505,7 @@ bool SSecurityRSAAES::readHash()
sha256_digest(&ctx, hashSize, realHash);
}
if (memcmp(hash, realHash, hashSize) != 0)
- throw ProtocolException("hash doesn't match");
+ throw protocol_error("hash doesn't match");
return true;
}
@@ -565,7 +565,7 @@ void SSecurityRSAAES::verifyUserPass()
#endif
if (!valid->validate(sc, username, password)) {
delete valid;
- throw AuthFailureException("Authentication failed");
+ throw auth_error("Authentication failed");
}
delete valid;
#else
@@ -592,7 +592,7 @@ void SSecurityRSAAES::verifyPass()
return;
}
- throw AuthFailureException("Authentication failed");
+ throw auth_error("Authentication failed");
}
const char* SSecurityRSAAES::getUserName() const
diff --git a/common/rfb/SSecurityTLS.cxx b/common/rfb/SSecurityTLS.cxx
index b8377e65..4b036e27 100644
--- a/common/rfb/SSecurityTLS.cxx
+++ b/common/rfb/SSecurityTLS.cxx
@@ -80,7 +80,7 @@ SSecurityTLS::SSecurityTLS(SConnection* sc_, bool _anon)
ret = gnutls_global_init();
if (ret != GNUTLS_E_SUCCESS)
- throw rdr::TLSException("gnutls_global_init()", ret);
+ throw rdr::tls_error("gnutls_global_init()", ret);
}
void SSecurityTLS::shutdown()
@@ -152,11 +152,11 @@ bool SSecurityTLS::processMsg()
err = gnutls_init(&session, GNUTLS_SERVER);
if (err != GNUTLS_E_SUCCESS)
- throw rdr::TLSException("gnutls_init()", err);
+ throw rdr::tls_error("gnutls_init()", err);
err = gnutls_set_default_priority(session);
if (err != GNUTLS_E_SUCCESS)
- throw rdr::TLSException("gnutls_set_default_priority()", err);
+ throw rdr::tls_error("gnutls_set_default_priority()", err);
try {
setParams();
@@ -186,7 +186,7 @@ bool SSecurityTLS::processMsg()
}
vlog.error("TLS Handshake failed: %s", gnutls_strerror (err));
shutdown();
- throw rdr::TLSException("TLS Handshake failed", err);
+ throw rdr::tls_error("TLS Handshake failed", err);
}
vlog.debug("TLS handshake completed with %s",
@@ -222,7 +222,7 @@ void SSecurityTLS::setParams()
if (ret != GNUTLS_E_SUCCESS) {
if (ret == GNUTLS_E_INVALID_REQUEST)
vlog.error("GnuTLS priority syntax error at: %s", err);
- throw rdr::TLSException("gnutls_set_priority_direct()", ret);
+ throw rdr::tls_error("gnutls_set_priority_direct()", ret);
}
} else if (anon) {
const char *err;
@@ -234,7 +234,7 @@ void SSecurityTLS::setParams()
if (ret != GNUTLS_E_SUCCESS) {
if (ret == GNUTLS_E_INVALID_REQUEST)
vlog.error("GnuTLS priority syntax error at: %s", err);
- throw rdr::TLSException("gnutls_set_default_priority_append()", ret);
+ throw rdr::tls_error("gnutls_set_default_priority_append()", ret);
}
#else
// We don't know what the system default priority is, so we guess
@@ -255,7 +255,7 @@ void SSecurityTLS::setParams()
if (ret != GNUTLS_E_SUCCESS) {
if (ret == GNUTLS_E_INVALID_REQUEST)
vlog.error("GnuTLS priority syntax error at: %s", err);
- throw rdr::TLSException("gnutls_set_priority_direct()", ret);
+ throw rdr::tls_error("gnutls_set_priority_direct()", ret);
}
#endif
}
@@ -263,18 +263,18 @@ void SSecurityTLS::setParams()
#if defined (SSECURITYTLS__USE_DEPRECATED_DH)
ret = gnutls_dh_params_init(&dh_params);
if (ret != GNUTLS_E_SUCCESS)
- throw rdr::TLSException("gnutls_dh_params_init()", ret);
+ throw rdr::tls_error("gnutls_dh_params_init()", ret);
ret = gnutls_dh_params_import_pkcs3(dh_params, &ffdhe_pkcs3_param,
GNUTLS_X509_FMT_PEM);
if (ret != GNUTLS_E_SUCCESS)
- throw rdr::TLSException("gnutls_dh_params_import_pkcs3()", ret);
+ throw rdr::tls_error("gnutls_dh_params_import_pkcs3()", ret);
#endif
if (anon) {
ret = gnutls_anon_allocate_server_credentials(&anon_cred);
if (ret != GNUTLS_E_SUCCESS)
- throw rdr::TLSException("gnutls_anon_allocate_server_credentials()", ret);
+ throw rdr::tls_error("gnutls_anon_allocate_server_credentials()", ret);
#if defined (SSECURITYTLS__USE_DEPRECATED_DH)
gnutls_anon_set_server_dh_params(anon_cred, dh_params);
@@ -282,14 +282,14 @@ void SSecurityTLS::setParams()
ret = gnutls_credentials_set(session, GNUTLS_CRD_ANON, anon_cred);
if (ret != GNUTLS_E_SUCCESS)
- throw rdr::TLSException("gnutls_credentials_set()", ret);
+ throw rdr::tls_error("gnutls_credentials_set()", ret);
vlog.debug("Anonymous session has been set");
} else {
ret = gnutls_certificate_allocate_credentials(&cert_cred);
if (ret != GNUTLS_E_SUCCESS)
- throw rdr::TLSException("gnutls_certificate_allocate_credentials()", ret);
+ throw rdr::tls_error("gnutls_certificate_allocate_credentials()", ret);
#if defined (SSECURITYTLS__USE_DEPRECATED_DH)
gnutls_certificate_set_dh_params(cert_cred, dh_params);
@@ -299,11 +299,11 @@ void SSecurityTLS::setParams()
X509_KeyFile,
GNUTLS_X509_FMT_PEM);
if (ret != GNUTLS_E_SUCCESS)
- throw rdr::TLSException("Failed to load certificate and key", ret);
+ throw rdr::tls_error("Failed to load certificate and key", ret);
ret = gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, cert_cred);
if (ret != GNUTLS_E_SUCCESS)
- throw rdr::TLSException("gnutls_credentials_set()", ret);
+ throw rdr::tls_error("gnutls_credentials_set()", ret);
vlog.debug("X509 session has been set");
diff --git a/common/rfb/SSecurityVeNCrypt.cxx b/common/rfb/SSecurityVeNCrypt.cxx
index e4347fb6..4617fddb 100644
--- a/common/rfb/SSecurityVeNCrypt.cxx
+++ b/common/rfb/SSecurityVeNCrypt.cxx
@@ -99,7 +99,7 @@ bool SSecurityVeNCrypt::processMsg()
case 0x0001: /* 0.1 Legacy VeNCrypt, not supported */
os->writeU8(0xFF); /* This is not OK */
os->flush();
- throw ProtocolException("The client cannot support the server's "
+ throw protocol_error("The client cannot support the server's "
"VeNCrypt version");
case 0x0002: /* 0.2 */
@@ -109,7 +109,7 @@ bool SSecurityVeNCrypt::processMsg()
default:
os->writeU8(0xFF); /* Not OK */
os->flush();
- throw ProtocolException("The client returned an unsupported VeNCrypt version");
+ throw protocol_error("The client returned an unsupported VeNCrypt version");
}
}
@@ -138,7 +138,7 @@ bool SSecurityVeNCrypt::processMsg()
os->flush();
haveSentTypes = true;
} else
- throw ProtocolException("There are no VeNCrypt sub-types to send to the client");
+ throw protocol_error("There are no VeNCrypt sub-types to send to the client");
}
/* get type back from client (must be one of the ones we sent) */
@@ -163,7 +163,7 @@ bool SSecurityVeNCrypt::processMsg()
/* Set up the stack according to the chosen type */
if (chosenType == secTypeInvalid || chosenType == secTypeVeNCrypt)
- throw ProtocolException("No valid VeNCrypt sub-type");
+ throw protocol_error("No valid VeNCrypt sub-type");
ssecurity = security->GetSSecurity(sc, chosenType);
}
diff --git a/common/rfb/SSecurityVncAuth.cxx b/common/rfb/SSecurityVncAuth.cxx
index b0401840..c4899aa9 100644
--- a/common/rfb/SSecurityVncAuth.cxx
+++ b/common/rfb/SSecurityVncAuth.cxx
@@ -113,7 +113,7 @@ bool SSecurityVncAuth::processMsg()
return true;
}
- throw AuthFailureException("Authentication failed");
+ throw auth_error("Authentication failed");
}
VncAuthPasswdParameter::VncAuthPasswdParameter(const char* name_,
diff --git a/common/rfb/TightDecoder.cxx b/common/rfb/TightDecoder.cxx
index ff05b279..ccf45a9d 100644
--- a/common/rfb/TightDecoder.cxx
+++ b/common/rfb/TightDecoder.cxx
@@ -104,14 +104,14 @@ bool TightDecoder::readRect(const Rect& r, rdr::InStream* is,
// Quit on unsupported compression type.
if (comp_ctl > tightMaxSubencoding)
- throw ProtocolException("TightDecoder: bad subencoding value received");
+ throw protocol_error("TightDecoder: bad subencoding value received");
// "Basic" compression type.
int palSize = 0;
if (r.width() > TIGHT_MAX_WIDTH)
- throw ProtocolException(format("TightDecoder: too large rectangle (%d pixels)", r.width()));
+ throw protocol_error(format("TightDecoder: too large rectangle (%d pixels)", r.width()));
// Possible palette
if ((comp_ctl & tightExplicitFilter) != 0) {
@@ -143,12 +143,12 @@ bool TightDecoder::readRect(const Rect& r, rdr::InStream* is,
break;
case tightFilterGradient:
if (server.pf().bpp == 8)
- throw ProtocolException("TightDecoder: invalid BPP for gradient filter");
+ throw protocol_error("TightDecoder: invalid BPP for gradient filter");
break;
case tightFilterCopy:
break;
default:
- throw ProtocolException("TightDecoder: unknown filter code received");
+ throw protocol_error("TightDecoder: unknown filter code received");
}
}
@@ -384,7 +384,7 @@ void TightDecoder::decodeRect(const Rect& r, const uint8_t* buffer,
netbuf = new uint8_t[dataSize];
if (!zis[streamId].hasData(dataSize))
- throw ProtocolException("Tight decode error");
+ throw protocol_error("Tight decode error");
zis[streamId].readBytes(netbuf, dataSize);
zis[streamId].flushUnderlying();
diff --git a/common/rfb/VNCSConnectionST.cxx b/common/rfb/VNCSConnectionST.cxx
index 6f207eb0..c1cb96f2 100644
--- a/common/rfb/VNCSConnectionST.cxx
+++ b/common/rfb/VNCSConnectionST.cxx
@@ -189,7 +189,7 @@ void VNCSConnectionST::processMessages()
// We wait until now with this to aggregate responses and to give
// higher priority to user actions such as keyboard and pointer events.
writeFramebufferUpdate();
- } catch (rdr::EndOfStream&) {
+ } catch (rdr::end_of_stream&) {
close("Clean disconnection");
} catch (std::exception& e) {
close(e.what());
@@ -730,7 +730,7 @@ void VNCSConnectionST::enableContinuousUpdates(bool enable,
Rect rect;
if (!client.supportsFence() || !client.supportsContinuousUpdates())
- throw ProtocolException("Client tried to enable continuous updates when not allowed");
+ throw protocol_error("Client tried to enable continuous updates when not allowed");
continuousUpdates = enable;
diff --git a/common/rfb/ZRLEDecoder.cxx b/common/rfb/ZRLEDecoder.cxx
index eab16baf..633d1c36 100644
--- a/common/rfb/ZRLEDecoder.cxx
+++ b/common/rfb/ZRLEDecoder.cxx
@@ -64,7 +64,7 @@ static inline T readPixel(rdr::ZlibInStream* zis)
static inline void zlibHasData(rdr::ZlibInStream* zis, size_t length)
{
if (!zis->hasData(length))
- throw ProtocolException("ZRLE decode error");
+ throw protocol_error("ZRLE decode error");
}
ZRLEDecoder::ZRLEDecoder() : Decoder(DecoderOrdered)
@@ -242,7 +242,7 @@ void ZRLEDecoder::zrleDecode(const Rect& r, rdr::InStream* is,
} while (b == 255);
if (end - ptr < len) {
- throw ProtocolException("ZRLE decode error");
+ throw protocol_error("ZRLE decode error");
}
while (len-- > 0) *ptr++ = pix;
@@ -267,7 +267,7 @@ void ZRLEDecoder::zrleDecode(const Rect& r, rdr::InStream* is,
} while (b == 255);
if (end - ptr < len) {
- throw ProtocolException("ZRLE decode error");
+ throw protocol_error("ZRLE decode error");
}
}