diff options
Diffstat (limited to 'common')
41 files changed, 243 insertions, 241 deletions
diff --git a/common/network/Socket.cxx b/common/network/Socket.cxx index 03844acd..879a63d0 100644 --- a/common/network/Socket.cxx +++ b/common/network/Socket.cxx @@ -55,7 +55,7 @@ void network::initSockets() { WSADATA initResult; if (WSAStartup(requiredVersion, &initResult) != 0) - throw rdr::SocketException("unable to initialise Winsock2", errorNumber); + throw rdr::socket_error("unable to initialise Winsock2", errorNumber); #else signal(SIGPIPE, SIG_IGN); #endif @@ -163,7 +163,7 @@ Socket* SocketListener::accept() { // Accept an incoming connection if ((new_sock = ::accept(fd, nullptr, nullptr)) < 0) - throw rdr::SocketException("unable to accept new connection", errorNumber); + throw rdr::socket_error("unable to accept new connection", errorNumber); // Create the socket object & check connection is allowed Socket* s = createSocket(new_sock); @@ -181,7 +181,7 @@ void SocketListener::listen(int sock) if (::listen(sock, 5) < 0) { int e = errorNumber; closesocket(sock); - throw rdr::SocketException("unable to set socket to listening mode", e); + throw rdr::socket_error("unable to set socket to listening mode", e); } fd = sock; diff --git a/common/network/TcpSocket.cxx b/common/network/TcpSocket.cxx index 455df749..bf603755 100644 --- a/common/network/TcpSocket.cxx +++ b/common/network/TcpSocket.cxx @@ -85,15 +85,15 @@ int network::findFreeTcpPort (void) addr.sin_addr.s_addr = INADDR_ANY; if ((sock = socket (AF_INET, SOCK_STREAM, 0)) < 0) - throw SocketException ("unable to create socket", errorNumber); + throw socket_error("unable to create socket", errorNumber); addr.sin_port = 0; if (bind (sock, (struct sockaddr *)&addr, sizeof (addr)) < 0) - throw SocketException ("unable to find free port", errorNumber); + throw socket_error("unable to find free port", errorNumber); socklen_t n = sizeof(addr); if (getsockname (sock, (struct sockaddr *)&addr, &n) < 0) - throw SocketException ("unable to get port number", errorNumber); + throw socket_error("unable to get port number", errorNumber); closesocket (sock); return ntohs(addr.sin_port); @@ -137,7 +137,7 @@ TcpSocket::TcpSocket(const char *host, int port) hints.ai_next = nullptr; if ((result = getaddrinfo(host, nullptr, &hints, &ai)) != 0) { - throw GAIException("unable to resolve host by name", result); + throw getaddrinfo_error("unable to resolve host by name", result); } sock = -1; @@ -178,7 +178,7 @@ TcpSocket::TcpSocket(const char *host, int port) if (sock == -1) { err = errorNumber; freeaddrinfo(ai); - throw SocketException("unable to create socket", err); + throw socket_error("unable to create socket", err); } /* Attempt to connect to the remote host */ @@ -205,7 +205,7 @@ TcpSocket::TcpSocket(const char *host, int port) if (err == 0) throw std::runtime_error("No useful address for host"); else - throw SocketException("unable to connect to socket", err); + throw socket_error("unable to connect to socket", err); } // Take proper ownership of the socket @@ -302,7 +302,7 @@ TcpListener::TcpListener(const struct sockaddr *listenaddr, int sock; if ((sock = socket (listenaddr->sa_family, SOCK_STREAM, 0)) < 0) - throw SocketException("unable to create listening socket", errorNumber); + throw socket_error("unable to create listening socket", errorNumber); memcpy (&sa, listenaddr, listenaddrlen); #ifdef IPV6_V6ONLY @@ -310,7 +310,7 @@ TcpListener::TcpListener(const struct sockaddr *listenaddr, if (setsockopt (sock, IPPROTO_IPV6, IPV6_V6ONLY, (char*)&one, sizeof(one))) { int e = errorNumber; closesocket(sock); - throw SocketException("unable to set IPV6_V6ONLY", e); + throw socket_error("unable to set IPV6_V6ONLY", e); } } #endif /* defined(IPV6_V6ONLY) */ @@ -328,14 +328,14 @@ TcpListener::TcpListener(const struct sockaddr *listenaddr, (char *)&one, sizeof(one)) < 0) { int e = errorNumber; closesocket(sock); - throw SocketException("unable to create listening socket", e); + throw socket_error("unable to create listening socket", e); } #endif if (bind(sock, &sa.u.sa, listenaddrlen) == -1) { int e = errorNumber; closesocket(sock); - throw SocketException("failed to bind socket", e); + throw socket_error("failed to bind socket", e); } listen(sock); @@ -446,7 +446,7 @@ void network::createTcpListeners(std::list<SocketListener*> *listeners, snprintf (service, sizeof (service) - 1, "%d", port); service[sizeof (service) - 1] = '\0'; if ((result = getaddrinfo(addr, service, &hints, &ai)) != 0) - throw GAIException("unable to resolve listening address", result); + throw getaddrinfo_error("unable to resolve listening address", result); try { createTcpListeners(listeners, ai); @@ -485,7 +485,7 @@ void network::createTcpListeners(std::list<SocketListener*> *listeners, try { new_listeners.push_back(new TcpListener(current->ai_addr, current->ai_addrlen)); - } catch (SocketException& e) { + } catch (socket_error& e) { // Ignore this if it is due to lack of address family support on // the interface or on the system if (e.err != EADDRNOTAVAIL && e.err != EAFNOSUPPORT) { @@ -633,7 +633,7 @@ TcpFilter::Pattern TcpFilter::parsePattern(const char* p) { } if ((result = getaddrinfo (parts[0].c_str(), nullptr, &hints, &ai)) != 0) { - throw GAIException("unable to resolve host by name", result); + throw getaddrinfo_error("unable to resolve host by name", result); } memcpy (&pattern.address.u.sa, ai->ai_addr, ai->ai_addrlen); diff --git a/common/network/UnixSocket.cxx b/common/network/UnixSocket.cxx index 4b82b4b7..c8517300 100644 --- a/common/network/UnixSocket.cxx +++ b/common/network/UnixSocket.cxx @@ -53,12 +53,12 @@ UnixSocket::UnixSocket(const char *path) socklen_t salen; if (strlen(path) >= sizeof(addr.sun_path)) - throw SocketException("socket path is too long", ENAMETOOLONG); + throw socket_error("socket path is too long", ENAMETOOLONG); // - Create a socket sock = socket(AF_UNIX, SOCK_STREAM, 0); if (sock == -1) - throw SocketException("unable to create socket", errno); + throw socket_error("unable to create socket", errno); // - Attempt to connect memset(&addr, 0, sizeof(addr)); @@ -72,7 +72,7 @@ UnixSocket::UnixSocket(const char *path) } if (result == -1) - throw SocketException("unable to connect to socket", err); + throw socket_error("unable to connect to socket", err); setFd(sock); } @@ -119,11 +119,11 @@ UnixListener::UnixListener(const char *path, int mode) int err, result; if (strlen(path) >= sizeof(addr.sun_path)) - throw SocketException("socket path is too long", ENAMETOOLONG); + throw socket_error("socket path is too long", ENAMETOOLONG); // - Create a socket if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) - throw SocketException("unable to create listening socket", errno); + throw socket_error("unable to create listening socket", errno); // - Delete existing socket (ignore result) unlink(path); @@ -138,14 +138,14 @@ UnixListener::UnixListener(const char *path, int mode) umask(saved_umask); if (result < 0) { close(fd); - throw SocketException("unable to bind listening socket", err); + throw socket_error("unable to bind listening socket", err); } // - Set socket mode if (chmod(path, mode) < 0) { err = errno; close(fd); - throw SocketException("unable to set socket mode", err); + throw socket_error("unable to set socket mode", err); } listen(fd); diff --git a/common/os/Mutex.cxx b/common/os/Mutex.cxx index b82de415..1889e66b 100644 --- a/common/os/Mutex.cxx +++ b/common/os/Mutex.cxx @@ -43,7 +43,7 @@ Mutex::Mutex() systemMutex = new pthread_mutex_t; ret = pthread_mutex_init((pthread_mutex_t*)systemMutex, nullptr); if (ret != 0) - throw rdr::PosixException("Failed to create mutex", ret); + throw rdr::posix_error("Failed to create mutex", ret); #endif } @@ -67,7 +67,7 @@ void Mutex::lock() ret = pthread_mutex_lock((pthread_mutex_t*)systemMutex); if (ret != 0) - throw rdr::PosixException("Failed to lock mutex", ret); + throw rdr::posix_error("Failed to lock mutex", ret); #endif } @@ -80,7 +80,7 @@ void Mutex::unlock() ret = pthread_mutex_unlock((pthread_mutex_t*)systemMutex); if (ret != 0) - throw rdr::PosixException("Failed to unlock mutex", ret); + throw rdr::posix_error("Failed to unlock mutex", ret); #endif } @@ -97,7 +97,7 @@ Condition::Condition(Mutex* mutex_) systemCondition = new pthread_cond_t; ret = pthread_cond_init((pthread_cond_t*)systemCondition, nullptr); if (ret != 0) - throw rdr::PosixException("Failed to create condition variable", ret); + throw rdr::posix_error("Failed to create condition variable", ret); #endif } @@ -120,14 +120,14 @@ void Condition::wait() (CRITICAL_SECTION*)mutex->systemMutex, INFINITE); if (!ret) - throw rdr::Win32Exception("Failed to wait on condition variable", GetLastError()); + throw rdr::win32_error("Failed to wait on condition variable", GetLastError()); #else int ret; ret = pthread_cond_wait((pthread_cond_t*)systemCondition, (pthread_mutex_t*)mutex->systemMutex); if (ret != 0) - throw rdr::PosixException("Failed to wait on condition variable", ret); + throw rdr::posix_error("Failed to wait on condition variable", ret); #endif } @@ -140,7 +140,7 @@ void Condition::signal() ret = pthread_cond_signal((pthread_cond_t*)systemCondition); if (ret != 0) - throw rdr::PosixException("Failed to signal condition variable", ret); + throw rdr::posix_error("Failed to signal condition variable", ret); #endif } @@ -153,6 +153,6 @@ void Condition::broadcast() ret = pthread_cond_broadcast((pthread_cond_t*)systemCondition); if (ret != 0) - throw rdr::PosixException("Failed to broadcast condition variable", ret); + throw rdr::posix_error("Failed to broadcast condition variable", ret); #endif } diff --git a/common/os/Thread.cxx b/common/os/Thread.cxx index e99be63e..6dca75a1 100644 --- a/common/os/Thread.cxx +++ b/common/os/Thread.cxx @@ -66,7 +66,7 @@ void Thread::start() #ifdef WIN32 *(HANDLE*)threadId = CreateThread(nullptr, 0, startRoutine, this, 0, nullptr); if (*(HANDLE*)threadId == nullptr) - throw rdr::Win32Exception("Failed to create thread", GetLastError()); + throw rdr::win32_error("Failed to create thread", GetLastError()); #else int ret; sigset_t all, old; @@ -76,14 +76,14 @@ void Thread::start() sigfillset(&all); ret = pthread_sigmask(SIG_SETMASK, &all, &old); if (ret != 0) - throw rdr::PosixException("Failed to mask signals", ret); + throw rdr::posix_error("Failed to mask signals", ret); ret = pthread_create((pthread_t*)threadId, nullptr, startRoutine, this); pthread_sigmask(SIG_SETMASK, &old, nullptr); if (ret != 0) - throw rdr::PosixException("Failed to create thread", ret); + throw rdr::posix_error("Failed to create thread", ret); #endif running = true; @@ -99,13 +99,13 @@ void Thread::wait() ret = WaitForSingleObject(*(HANDLE*)threadId, INFINITE); if (ret != WAIT_OBJECT_0) - throw rdr::Win32Exception("Failed to join thread", GetLastError()); + throw rdr::win32_error("Failed to join thread", GetLastError()); #else int ret; ret = pthread_join(*(pthread_t*)threadId, nullptr); if (ret != 0) - throw rdr::PosixException("Failed to join thread", ret); + throw rdr::posix_error("Failed to join thread", ret); #endif } diff --git a/common/rdr/Exception.cxx b/common/rdr/Exception.cxx index 65bd9720..694ee359 100644 --- a/common/rdr/Exception.cxx +++ b/common/rdr/Exception.cxx @@ -43,21 +43,21 @@ using namespace rdr; -GAIException::GAIException(const char* s, int err_) +getaddrinfo_error::getaddrinfo_error(const char* s, int err_) : std::runtime_error(rfb::format("%s: %s (%d)", s, strerror(err_).c_str(), err_)), err(err_) { } -GAIException::GAIException(const std::string& s, int err_) +getaddrinfo_error::getaddrinfo_error(const std::string& s, int err_) : std::runtime_error(rfb::format("%s: %s (%d)", s.c_str(), strerror(err_).c_str(), err_)), err(err_) { } -std::string GAIException::strerror(int err_) const +std::string getaddrinfo_error::strerror(int err_) const { #ifdef _WIN32 char str[256]; @@ -71,21 +71,21 @@ std::string GAIException::strerror(int err_) const #endif } -PosixException::PosixException(const char* what_arg, int err_) +posix_error::posix_error(const char* what_arg, int err_) : std::runtime_error(rfb::format("%s: %s (%d)", what_arg, strerror(err_).c_str(), err_)), err(err_) { } -PosixException::PosixException(const std::string& what_arg, int err_) +posix_error::posix_error(const std::string& what_arg, int err_) : std::runtime_error(rfb::format("%s: %s (%d)", what_arg.c_str(), strerror(err_).c_str(), err_)), err(err_) { } -std::string PosixException::strerror(int err_) const +std::string posix_error::strerror(int err_) const { #ifdef _WIN32 char str[256]; @@ -100,21 +100,21 @@ std::string PosixException::strerror(int err_) const } #ifdef WIN32 -Win32Exception::Win32Exception(const char* what_arg, unsigned err_) +win32_error::win32_error(const char* what_arg, unsigned err_) : std::runtime_error(rfb::format("%s: %s (%d)", what_arg, strerror(err_).c_str(), err_)), err(err_) { } -Win32Exception::Win32Exception(const std::string& what_arg, unsigned err_) +win32_error::win32_error(const std::string& what_arg, unsigned err_) : std::runtime_error(rfb::format("%s: %s (%d)", what_arg.c_str(), strerror(err_).c_str(), err_)), err(err_) { } -std::string Win32Exception::strerror(unsigned err_) const +std::string win32_error::strerror(unsigned err_) const { wchar_t wstr[256]; char str[256]; diff --git a/common/rdr/Exception.h b/common/rdr/Exception.h index 3e0ec467..f3f878cb 100644 --- a/common/rdr/Exception.h +++ b/common/rdr/Exception.h @@ -27,52 +27,52 @@ namespace rdr { - class PosixException : public std::runtime_error { + class posix_error : public std::runtime_error { public: int err; - PosixException(const char* what_arg, int err_); - PosixException(const std::string& what_arg, int err_); + posix_error(const char* what_arg, int err_); + posix_error(const std::string& what_arg, int err_); private: std::string strerror(int err_) const; }; #ifdef WIN32 - class Win32Exception : public std::runtime_error { + class win32_error : public std::runtime_error { public: unsigned err; - Win32Exception(const char* what_arg, unsigned err_); - Win32Exception(const std::string& what_arg, unsigned err_); + win32_error(const char* what_arg, unsigned err_); + win32_error(const std::string& what_arg, unsigned err_); private: std::string strerror(unsigned err_) const; }; #endif #ifdef WIN32 - class SocketException : public Win32Exception { + class socket_error : public win32_error { public: - SocketException(const char* what_arg, unsigned err_) : Win32Exception(what_arg, err_) {} - SocketException(const std::string& what_arg, unsigned err_) : Win32Exception(what_arg, err_) {} + socket_error(const char* what_arg, unsigned err_) : win32_error(what_arg, err_) {} + socket_error(const std::string& what_arg, unsigned err_) : win32_error(what_arg, err_) {} }; #else - class SocketException : public PosixException { + class socket_error : public posix_error { public: - SocketException(const char* what_arg, unsigned err_) : PosixException(what_arg, err_) {} - SocketException(const std::string& what_arg, unsigned err_) : PosixException(what_arg, err_) {} + socket_error(const char* what_arg, unsigned err_) : posix_error(what_arg, err_) {} + socket_error(const std::string& what_arg, unsigned err_) : posix_error(what_arg, err_) {} }; #endif - class GAIException : public std::runtime_error { + class getaddrinfo_error : public std::runtime_error { public: int err; - GAIException(const char* s, int err_); - GAIException(const std::string& s, int err_); + getaddrinfo_error(const char* s, int err_); + getaddrinfo_error(const std::string& s, int err_); private: std::string strerror(int err_) const; }; - class EndOfStream : public std::runtime_error { + class end_of_stream : public std::runtime_error { public: - EndOfStream() : std::runtime_error("End of stream") {} + end_of_stream() : std::runtime_error("End of stream") {} }; } diff --git a/common/rdr/FdInStream.cxx b/common/rdr/FdInStream.cxx index bddee482..23ea2f8c 100644 --- a/common/rdr/FdInStream.cxx +++ b/common/rdr/FdInStream.cxx @@ -92,7 +92,7 @@ size_t FdInStream::readFd(uint8_t* buf, size_t len) } while (n < 0 && errorNumber == EINTR); if (n < 0) - throw SocketException("select", errorNumber); + throw socket_error("select", errorNumber); if (n == 0) return 0; @@ -102,9 +102,9 @@ size_t FdInStream::readFd(uint8_t* buf, size_t len) } while (n < 0 && errorNumber == EINTR); if (n < 0) - throw SocketException("read", errorNumber); + throw socket_error("read", errorNumber); if (n == 0) - throw EndOfStream(); + throw end_of_stream(); return n; } diff --git a/common/rdr/FdOutStream.cxx b/common/rdr/FdOutStream.cxx index 1b6049ca..6db8c0bb 100644 --- a/common/rdr/FdOutStream.cxx +++ b/common/rdr/FdOutStream.cxx @@ -117,7 +117,7 @@ size_t FdOutStream::writeFd(const uint8_t* data, size_t length) } while (n < 0 && errorNumber == EINTR); if (n < 0) - throw SocketException("select", errorNumber); + throw socket_error("select", errorNumber); if (n == 0) return 0; @@ -134,7 +134,7 @@ size_t FdOutStream::writeFd(const uint8_t* data, size_t length) } while (n < 0 && (errorNumber == EINTR)); if (n < 0) - throw SocketException("write", errorNumber); + throw socket_error("write", errorNumber); gettimeofday(&lastWrite, nullptr); diff --git a/common/rdr/FileInStream.cxx b/common/rdr/FileInStream.cxx index db646a7e..df09ea76 100644 --- a/common/rdr/FileInStream.cxx +++ b/common/rdr/FileInStream.cxx @@ -33,7 +33,7 @@ FileInStream::FileInStream(const char *fileName) { file = fopen(fileName, "rb"); if (!file) - throw PosixException("fopen", errno); + throw posix_error("fopen", errno); } FileInStream::~FileInStream(void) { @@ -48,9 +48,9 @@ bool FileInStream::fillBuffer() size_t n = fread((uint8_t*)end, 1, availSpace(), file); if (n == 0) { if (ferror(file)) - throw PosixException("fread", errno); + throw posix_error("fread", errno); if (feof(file)) - throw EndOfStream(); + throw end_of_stream(); return false; } end += n; diff --git a/common/rdr/MemInStream.h b/common/rdr/MemInStream.h index e10273b1..78ee2dee 100644 --- a/common/rdr/MemInStream.h +++ b/common/rdr/MemInStream.h @@ -59,7 +59,7 @@ namespace rdr { private: - bool overrun(size_t /*needed*/) override { throw EndOfStream(); } + bool overrun(size_t /*needed*/) override { throw end_of_stream(); } const uint8_t* start; bool deleteWhenDone; }; diff --git a/common/rdr/RandomStream.cxx b/common/rdr/RandomStream.cxx index 449a84c0..485259cf 100644 --- a/common/rdr/RandomStream.cxx +++ b/common/rdr/RandomStream.cxx @@ -89,7 +89,7 @@ bool RandomStream::fillBuffer() { #ifdef RFB_HAVE_WINCRYPT if (provider) { if (!CryptGenRandom(provider, availSpace(), (uint8_t*)end)) - throw rdr::Win32Exception("unable to CryptGenRandom", GetLastError()); + throw rdr::win32_error("unable to CryptGenRandom", GetLastError()); end += availSpace(); } else { #else @@ -97,8 +97,8 @@ bool RandomStream::fillBuffer() { if (fp) { size_t n = fread((uint8_t*)end, 1, availSpace(), fp); if (n <= 0) - throw rdr::PosixException("reading /dev/urandom or /dev/random failed", - errno); + throw rdr::posix_error("reading /dev/urandom or /dev/random " + "failed", errno); end += n; } else { #else diff --git a/common/rdr/TLSException.cxx b/common/rdr/TLSException.cxx index 7061f38b..ccff6090 100644 --- a/common/rdr/TLSException.cxx +++ b/common/rdr/TLSException.cxx @@ -35,7 +35,7 @@ using namespace rdr; #ifdef HAVE_GNUTLS -TLSException::TLSException(const char* s, int err_) +tls_error::tls_error(const char* s, int err_) : std::runtime_error(rfb::format("%s: %s (%d)", s, gnutls_strerror(err_), err_)), err(err_) diff --git a/common/rdr/TLSException.h b/common/rdr/TLSException.h index f58b618d..cfa73f69 100644 --- a/common/rdr/TLSException.h +++ b/common/rdr/TLSException.h @@ -25,10 +25,10 @@ namespace rdr { - class TLSException : public std::runtime_error { + class tls_error : public std::runtime_error { public: int err; - TLSException(const char* s, int err_); + tls_error(const char* s, int err_); }; } diff --git a/common/rdr/TLSInStream.cxx b/common/rdr/TLSInStream.cxx index 3418c68e..7c867e88 100644 --- a/common/rdr/TLSInStream.cxx +++ b/common/rdr/TLSInStream.cxx @@ -54,12 +54,12 @@ ssize_t TLSInStream::pull(gnutls_transport_ptr_t str, void* data, size_t size) size = in->avail(); in->readBytes((uint8_t*)data, size); - } catch (EndOfStream&) { + } catch (end_of_stream&) { return 0; - } catch (SocketException& e) { + } catch (socket_error& e) { vlog.error("Failure reading TLS data: %s", e.what()); gnutls_transport_set_errno(self->session, e.err); - self->saved_exception = new SocketException(e); + self->saved_exception = new socket_error(e); return -1; } catch (std::exception& e) { vlog.error("Failure reading TLS data: %s", e.what()); @@ -121,10 +121,10 @@ size_t TLSInStream::readTLS(uint8_t* buf, size_t len) throw *saved_exception; if (n < 0) - throw TLSException("readTLS", n); + throw tls_error("readTLS", n); if (n == 0) - throw EndOfStream(); + throw end_of_stream(); return n; } diff --git a/common/rdr/TLSOutStream.cxx b/common/rdr/TLSOutStream.cxx index 4c6c3f47..1e555fc1 100644 --- a/common/rdr/TLSOutStream.cxx +++ b/common/rdr/TLSOutStream.cxx @@ -46,10 +46,10 @@ ssize_t TLSOutStream::push(gnutls_transport_ptr_t str, const void* data, try { out->writeBytes((const uint8_t*)data, size); out->flush(); - } catch (SocketException& e) { + } catch (socket_error& e) { vlog.error("Failure sending TLS data: %s", e.what()); gnutls_transport_set_errno(self->session, e.err); - self->saved_exception = new SocketException(e); + self->saved_exception = new socket_error(e); return -1; } catch (std::exception& e) { vlog.error("Failure sending TLS data: %s", e.what()); @@ -118,7 +118,7 @@ size_t TLSOutStream::writeTLS(const uint8_t* data, size_t length) throw *saved_exception; if (n < 0) - throw TLSException("writeTLS", n); + throw tls_error("writeTLS", n); return n; } 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"); } } |