From: Pierre Ossman Date: Fri, 22 Nov 2024 12:23:03 +0000 (+0100) Subject: Merge branch 'master' of https://github.com/madnicendio/tigervnc X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=9366d8e54c5ee1c2cfcf333a17b7fd4bdbd13993;p=tigervnc.git Merge branch 'master' of https://github.com/madnicendio/tigervnc --- 9366d8e54c5ee1c2cfcf333a17b7fd4bdbd13993 diff --cc common/network/TcpSocket.cxx index bf603755,76055abb..e37861f4 --- a/common/network/TcpSocket.cxx +++ b/common/network/TcpSocket.cxx @@@ -302,7 -299,7 +302,7 @@@ TcpListener::TcpListener(const struct s int sock; if ((sock = socket (listenaddr->sa_family, SOCK_STREAM, 0)) < 0) - throw socket_error("unable to create listening socket", errorNumber); - 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 -307,7 +310,7 @@@ if (setsockopt (sock, IPPROTO_IPV6, IPV6_V6ONLY, (char*)&one, sizeof(one))) { int e = errorNumber; closesocket(sock); - throw socket_error("unable to set IPV6_V6ONLY", e); - throw SocketException("Unable to set IPV6_V6ONLY", e); ++ throw socket_error("Unable to set IPV6_V6ONLY", e); } } #endif /* defined(IPV6_V6ONLY) */ @@@ -328,14 -325,14 +328,14 @@@ (char *)&one, sizeof(one)) < 0) { int e = errorNumber; closesocket(sock); - throw socket_error("unable to create listening socket", e); - 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 socket_error("failed to bind socket", e); - throw SocketException("Failed to bind socket", e); ++ throw socket_error("Failed to bind socket", e); } listen(sock); @@@ -446,7 -443,7 +446,7 @@@ void network::createTcpListeners(std::l snprintf (service, sizeof (service) - 1, "%d", port); service[sizeof (service) - 1] = '\0'; if ((result = getaddrinfo(addr, service, &hints, &ai)) != 0) - throw getaddrinfo_error("unable to resolve listening address", result); - throw GAIException("Unable to resolve listening address", result); ++ throw getaddrinfo_error("Unable to resolve listening address", result); try { createTcpListeners(listeners, ai); @@@ -633,7 -630,7 +633,7 @@@ TcpFilter::Pattern TcpFilter::parsePatt } if ((result = getaddrinfo (parts[0].c_str(), nullptr, &hints, &ai)) != 0) { - throw getaddrinfo_error("unable to resolve host by name", result); - 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); @@@ -644,8 -641,8 +644,8 @@@ if (parts.size() > 1) { if (family == AF_INET && (parts[1].find('.') != std::string::npos)) { - throw std::invalid_argument("mask no longer supported for " - throw Exception("Mask no longer supported for filter, " - "use prefix instead"); ++ throw std::invalid_argument("Mask no longer supported for " + "filter, use prefix instead"); } pattern.prefixlen = (unsigned int) atoi(parts[1].c_str()); diff --cc common/network/UnixSocket.cxx index c8517300,fb631dae..fb017a53 --- a/common/network/UnixSocket.cxx +++ b/common/network/UnixSocket.cxx @@@ -72,7 -69,7 +72,7 @@@ UnixSocket::UnixSocket(const char *path } if (result == -1) - throw socket_error("unable to connect to socket", err); - throw SocketException("Unable to connect to socket", err); ++ throw socket_error("Unable to connect to socket", err); setFd(sock); } @@@ -123,7 -120,7 +123,7 @@@ UnixListener::UnixListener(const char * // - Create a socket if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) - throw socket_error("unable to create listening socket", errno); - 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 -135,14 +138,14 @@@ umask(saved_umask); if (result < 0) { close(fd); - throw socket_error("unable to bind listening socket", err); - 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 socket_error("unable to set socket mode", err); - throw SocketException("Unable to set socket mode", err); ++ throw socket_error("Unable to set socket mode", err); } listen(fd); diff --cc common/rdr/RandomStream.cxx index 485259cf,b045d48a..3a524102 --- a/common/rdr/RandomStream.cxx +++ b/common/rdr/RandomStream.cxx @@@ -89,7 -89,7 +89,7 @@@ bool RandomStream::fillBuffer() #ifdef RFB_HAVE_WINCRYPT if (provider) { if (!CryptGenRandom(provider, availSpace(), (uint8_t*)end)) - throw rdr::win32_error("unable to CryptGenRandom", GetLastError()); - throw rdr::Win32Exception("Unable to CryptGenRandom", GetLastError()); ++ throw rdr::win32_error("Unable to CryptGenRandom", GetLastError()); end += availSpace(); } else { #else @@@ -97,8 -97,8 +97,8 @@@ if (fp) { size_t n = fread((uint8_t*)end, 1, availSpace(), fp); if (n <= 0) - throw rdr::posix_error("reading /dev/urandom or /dev/random " - 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 --cc common/rfb/CConnection.cxx index c6feef9f,a682b810..e8451337 --- a/common/rfb/CConnection.cxx +++ b/common/rfb/CConnection.cxx @@@ -323,13 -321,13 +323,13 @@@ bool CConnection::processSecurityResult securityCompleted(); return true; case secResultFailed: - vlog.debug("auth failed"); + vlog.debug("Auth failed"); break; case secResultTooMany: - vlog.debug("auth failed - too many tries"); + vlog.debug("Auth failed: Too many tries"); break; default: - throw Exception("Unknown security result from server"); + throw protocol_error("Unknown security result from server"); } if (server.beforeVersion(3,8)) { diff --cc common/rfb/CSecurityTLS.cxx index 3761ca30,3b7868ba..9072ce50 --- a/common/rfb/CSecurityTLS.cxx +++ b/common/rfb/CSecurityTLS.cxx @@@ -316,8 -320,8 +316,8 @@@ void CSecurityTLS::checkSession( err = gnutls_certificate_verify_peers2(session, &status); if (err != 0) { - vlog.error("server certificate verification failed: %s", gnutls_strerror(err)); + 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) { diff --cc common/rfb/Configuration.cxx index 8f7cb6a7,763a5635..44d42a88 --- a/common/rfb/Configuration.cxx +++ b/common/rfb/Configuration.cxx @@@ -388,8 -387,8 +388,8 @@@ bool StringParameter::setParam(const ch LOCK_CONFIG; if (immutable) return true; if (!v) - throw rfb::Exception("setParam() not allowed"); + throw std::invalid_argument("setParam() not allowed"); - vlog.debug("set %s(String) to %s", getName(), v); + vlog.debug("Set %s(String) to %s", getName(), v); value = v; return true; } diff --cc win/rfb_win32/Clipboard.cxx index 8577df46,d3b99200..2a2be1d5 --- a/win/rfb_win32/Clipboard.cxx +++ b/win/rfb_win32/Clipboard.cxx @@@ -148,12 -146,12 +148,12 @@@ Clipboard::setClipText(const char* text // - Set the new clipboard data if (!SetClipboardData(CF_UNICODETEXT, clip_handle)) - throw rdr::Win32Exception("unable to set Win32 clipboard", GetLastError()); + throw rdr::win32_error("unable to set Win32 clipboard", GetLastError()); clip_handle = nullptr; - vlog.debug("set clipboard"); + vlog.debug("Set clipboard"); - } catch (rdr::Exception& e) { - vlog.debug("%s", e.str()); + } catch (std::exception& e) { + vlog.debug("%s", e.what()); } // - Close the clipboard diff --cc win/rfb_win32/DeviceContext.cxx index 1c64e1f5,e6dc8508..353ee716 --- a/win/rfb_win32/DeviceContext.cxx +++ b/win/rfb_win32/DeviceContext.cxx @@@ -86,8 -86,8 +86,8 @@@ PixelFormat DeviceContext::getPF(HDC dc bMask = 0x0000ff; break; default: - vlog.error("bits per pixel %u not supported", bi.bmiHeader.biBitCount); + vlog.error("Bits per pixel %u not supported", bi.bmiHeader.biBitCount); - throw rdr::Exception("unknown bits per pixel specified"); + throw std::invalid_argument("unknown bits per pixel specified"); }; break; case BI_BITFIELDS: diff --cc win/rfb_win32/MonitorInfo.cxx index 84a8d501,f35ef69e..9f7c2daf --- a/win/rfb_win32/MonitorInfo.cxx +++ b/win/rfb_win32/MonitorInfo.cxx @@@ -44,10 -44,10 +44,10 @@@ static void fillMonitorInfo(HMONITOR mo memset(mi, 0, sizeof(MONITORINFOEXA)); mi->cbSize = sizeof(MONITORINFOEXA); if (!GetMonitorInfo(monitor, mi)) - throw rdr::Win32Exception("failed to GetMonitorInfo", GetLastError()); + throw rdr::win32_error("failed to GetMonitorInfo", GetLastError()); - vlog.debug("monitor is %ld,%ld-%ld,%ld", mi->rcMonitor.left, mi->rcMonitor.top, mi->rcMonitor.right, mi->rcMonitor.bottom); - vlog.debug("work area is %ld,%ld-%ld,%ld", mi->rcWork.left, mi->rcWork.top, mi->rcWork.right, mi->rcWork.bottom); - vlog.debug("device is \"%s\"", mi->szDevice); + vlog.debug("Monitor is %ld,%ld-%ld,%ld", mi->rcMonitor.left, mi->rcMonitor.top, mi->rcMonitor.right, mi->rcMonitor.bottom); + vlog.debug("Work area is %ld,%ld-%ld,%ld", mi->rcWork.left, mi->rcWork.top, mi->rcWork.right, mi->rcWork.bottom); + vlog.debug("Device is \"%s\"", mi->szDevice); } diff --cc win/rfb_win32/MsgWindow.cxx index 4908126e,8f15c41d..bd35ca0f --- a/win/rfb_win32/MsgWindow.cxx +++ b/win/rfb_win32/MsgWindow.cxx @@@ -61,8 -61,8 +61,8 @@@ LRESULT CALLBACK MsgWindowProc(HWND wnd try { result = _this->processMessage(msg, wParam, lParam); - } catch (rdr::Exception& e) { - vlog.error("Untrapped: %s", e.str()); + } catch (std::exception& e) { - vlog.error("untrapped: %s", e.what()); ++ vlog.error("Untrapped: %s", e.what()); } return result; @@@ -104,9 -104,9 +104,9 @@@ MsgWindow::MsgWindow(const char* name_ name.c_str(), WS_OVERLAPPED, 0, 0, 10, 10, nullptr, nullptr, baseClass.instance, this); if (!handle) { - throw rdr::Win32Exception("unable to create WMNotifier window instance", GetLastError()); + throw rdr::win32_error("unable to create WMNotifier window instance", GetLastError()); } - vlog.debug("created window \"%s\" (%p)", name.c_str(), handle); + vlog.debug("Created window \"%s\" (%p)", name.c_str(), handle); } MsgWindow::~MsgWindow() { diff --cc win/rfb_win32/RegConfig.cxx index 211570ca,d95166f4..d9835201 --- a/win/rfb_win32/RegConfig.cxx +++ b/win/rfb_win32/RegConfig.cxx @@@ -67,11 -67,11 +67,11 @@@ void RegConfig::loadRegistryConfig(RegK if (!name) break; std::string value = key.getRepresentation(name); if (!Configuration::setParam(name, value.c_str())) - vlog.info("unable to process %s", name); + vlog.info("Unable to process %s", name); } - } catch (rdr::Win32Exception& e) { + } catch (rdr::win32_error& e) { if (e.err != ERROR_INVALID_HANDLE) - vlog.error("%s", e.str()); + vlog.error("%s", e.what()); } } diff --cc win/rfb_win32/Registry.cxx index 47756950,4aa0e013..27e55a2e --- a/win/rfb_win32/Registry.cxx +++ b/win/rfb_win32/Registry.cxx @@@ -54,16 -54,16 +54,16 @@@ RegKey::RegKey() : key(nullptr), freeKe RegKey::RegKey(const HKEY k) : key(nullptr), freeKey(false), valueName(nullptr), valueNameBufLen(0) { LONG result = RegOpenKeyEx(k, nullptr, 0, KEY_ALL_ACCESS, &key); if (result != ERROR_SUCCESS) - throw rdr::Win32Exception("RegOpenKeyEx(HKEY)", result); + throw rdr::win32_error("RegOpenKeyEx(HKEY)", result); - vlog.debug("duplicated %p to %p", k, key); + vlog.debug("Duplicated %p to %p", k, key); freeKey = true; } RegKey::RegKey(const RegKey& k) : key(nullptr), freeKey(false), valueName(nullptr), valueNameBufLen(0) { LONG result = RegOpenKeyEx(k.key, nullptr, 0, KEY_ALL_ACCESS, &key); if (result != ERROR_SUCCESS) - throw rdr::Win32Exception("RegOpenKeyEx(RegKey&)", result); + throw rdr::win32_error("RegOpenKeyEx(RegKey&)", result); - vlog.debug("duplicated %p to %p", k.key, key); + vlog.debug("Duplicated %p to %p", k.key, key); freeKey = true; } diff --cc win/rfb_win32/SDisplay.cxx index 33f2d6c9,1c269dd5..ee339649 --- a/win/rfb_win32/SDisplay.cxx +++ b/win/rfb_win32/SDisplay.cxx @@@ -285,8 -286,8 +285,8 @@@ void SDisplay::restartCore() try { // Start a new Core if possible startCore(); - vlog.info("restarted"); + vlog.info("Restarted"); - } catch (rdr::Exception& e) { + } catch (std::exception& e) { // If startCore() fails then we MUST disconnect all clients, // to cause the server to stop() the desktop. // Otherwise, the SDesktop is in an inconsistent state diff --cc win/rfb_win32/Service.cxx index 907e3214,86e1dc5c..bc9875e5 --- a/win/rfb_win32/Service.cxx +++ b/win/rfb_win32/Service.cxx @@@ -110,12 -110,12 +110,12 @@@ Service::start() entry[0].lpServiceProc = serviceProc; entry[1].lpServiceName = nullptr; entry[1].lpServiceProc = nullptr; - vlog.debug("entering dispatcher"); + vlog.debug("Entering dispatcher"); if (!SetProcessShutdownParameters(0x100, 0)) - vlog.error("unable to set shutdown parameters: %lu", GetLastError()); + vlog.error("Unable to set shutdown parameters: %lu", GetLastError()); service = this; if (!StartServiceCtrlDispatcher(entry)) - throw win32_error("unable to start service", GetLastError()); - throw Win32Exception("Unable to start service", GetLastError()); ++ throw win32_error("Unable to start service", GetLastError()); } void @@@ -335,7 -335,7 +335,7 @@@ bool rfb::win32::registerService(const // - Open the SCM ServiceHandle scm = OpenSCManager(nullptr, nullptr, SC_MANAGER_CREATE_SERVICE); if (!scm) - throw rdr::win32_error("unable to open Service Control Manager", GetLastError()); - throw rdr::Win32Exception("Unable to open service control manager", GetLastError()); ++ throw rdr::win32_error("Unable to open Service Control Manager", GetLastError()); // - Add the service ServiceHandle handle = CreateService(scm, @@@ -344,7 -344,7 +344,7 @@@ SERVICE_AUTO_START, SERVICE_ERROR_IGNORE, cmdline.c_str(), nullptr, nullptr, nullptr, nullptr, nullptr); if (!handle) - throw rdr::win32_error("unable to create service", GetLastError()); - throw rdr::Win32Exception("Unable to create service", GetLastError()); ++ throw rdr::win32_error("Unable to create service", GetLastError()); // - Set a description SERVICE_DESCRIPTION sdesc = {(LPTSTR)desc}; @@@ -380,14 -380,14 +380,14 @@@ bool rfb::win32::unregisterService(cons // - Open the SCM ServiceHandle scm = OpenSCManager(nullptr, nullptr, SC_MANAGER_CREATE_SERVICE); if (!scm) - throw rdr::win32_error("unable to open Service Control Manager", GetLastError()); - throw rdr::Win32Exception("Unable to open service control manager", GetLastError()); ++ throw rdr::win32_error("Unable to open Service Control Manager", GetLastError()); // - Create the service ServiceHandle handle = OpenService(scm, name, SC_MANAGER_ALL_ACCESS); if (!handle) - throw rdr::win32_error("unable to locate the service", GetLastError()); - throw rdr::Win32Exception("Unable to locate the service", GetLastError()); ++ throw rdr::win32_error("Unable to locate the service", GetLastError()); if (!DeleteService(handle)) - throw rdr::win32_error("unable to remove the service", GetLastError()); - throw rdr::Win32Exception("Unable to remove the service", GetLastError()); ++ throw rdr::win32_error("Unable to remove the service", GetLastError()); // - Register the event log source RegKey hk; @@@ -407,16 -407,16 +407,16 @@@ bool rfb::win32::startService(const cha // - Open the SCM ServiceHandle scm = OpenSCManager(nullptr, nullptr, SC_MANAGER_CONNECT); if (!scm) - throw rdr::win32_error("unable to open Service Control Manager", GetLastError()); - throw rdr::Win32Exception("Unable to open service control manager", GetLastError()); ++ throw rdr::win32_error("Unable to open Service Control Manager", GetLastError()); // - Locate the service ServiceHandle handle = OpenService(scm, name, SERVICE_START); if (!handle) - throw rdr::win32_error("unable to open the service", GetLastError()); - throw rdr::Win32Exception("Unable to open the service", GetLastError()); ++ throw rdr::win32_error("Unable to open the service", GetLastError()); // - Start the service if (!StartService(handle, 0, nullptr)) - throw rdr::win32_error("unable to start the service", GetLastError()); - throw rdr::Win32Exception("Unable to start the service", GetLastError()); ++ throw rdr::win32_error("Unable to start the service", GetLastError()); Sleep(500); @@@ -427,17 -427,17 +427,17 @@@ bool rfb::win32::stopService(const char // - Open the SCM ServiceHandle scm = OpenSCManager(nullptr, nullptr, SC_MANAGER_CONNECT); if (!scm) - throw rdr::win32_error("unable to open Service Control Manager", GetLastError()); - throw rdr::Win32Exception("Unable to open service control manager", GetLastError()); ++ throw rdr::win32_error("Unable to open Service Control Manager", GetLastError()); // - Locate the service ServiceHandle handle = OpenService(scm, name, SERVICE_STOP); if (!handle) - throw rdr::win32_error("unable to open the service", GetLastError()); - throw rdr::Win32Exception("Unable to open the service", GetLastError()); ++ throw rdr::win32_error("Unable to open the service", GetLastError()); // - Start the service SERVICE_STATUS status; if (!ControlService(handle, SERVICE_CONTROL_STOP, &status)) - throw rdr::win32_error("unable to stop the service", GetLastError()); - throw rdr::Win32Exception("Unable to stop the service", GetLastError()); ++ throw rdr::win32_error("Unable to stop the service", GetLastError()); Sleep(500); @@@ -448,17 -448,17 +448,17 @@@ DWORD rfb::win32::getServiceState(cons // - Open the SCM ServiceHandle scm = OpenSCManager(nullptr, nullptr, SC_MANAGER_CONNECT); if (!scm) - throw rdr::win32_error("unable to open Service Control Manager", GetLastError()); - throw rdr::Win32Exception("Unable to open service control manager", GetLastError()); ++ throw rdr::win32_error("Unable to open Service Control Manager", GetLastError()); // - Locate the service ServiceHandle handle = OpenService(scm, name, SERVICE_INTERROGATE); if (!handle) - throw rdr::win32_error("unable to open the service", GetLastError()); - throw rdr::Win32Exception("Unable to open the service", GetLastError()); ++ throw rdr::win32_error("Unable to open the service", GetLastError()); // - Get the service status SERVICE_STATUS status; if (!ControlService(handle, SERVICE_CONTROL_INTERROGATE, (SERVICE_STATUS*)&status)) - throw rdr::win32_error("unable to query the service", GetLastError()); - throw rdr::Win32Exception("Unable to query the service", GetLastError()); ++ throw rdr::win32_error("Unable to query the service", GetLastError()); return status.dwCurrentState; } diff --cc win/rfb_win32/SocketManager.cxx index b42c66cb,9fdecb94..7f6d1773 --- a/win/rfb_win32/SocketManager.cxx +++ b/win/rfb_win32/SocketManager.cxx @@@ -236,7 -234,7 +236,7 @@@ void SocketManager::processEvent(HANDL // Fetch why this event notification triggered if (WSAEnumNetworkEvents(ci.sock->getFd(), event, &network_events) == SOCKET_ERROR) - throw rdr::socket_error("unable to get WSAEnumNetworkEvents:%u", WSAGetLastError()); - throw rdr::SocketException("Unable to get WSAEnumNetworkEvents:%u", WSAGetLastError()); ++ throw rdr::socket_error("Unable to get WSAEnumNetworkEvents:%u", WSAGetLastError()); // Cancel event notification for this socket if (WSAEventSelect(ci.sock->getFd(), event, 0) == SOCKET_ERROR) diff --cc win/vncconfig/Legacy.cxx index c6b245cc,5c9dac3a..3280eaef --- a/win/vncconfig/Legacy.cxx +++ b/win/vncconfig/Legacy.cxx @@@ -143,10 -143,10 +143,10 @@@ void LegacyPage::LoadPrefs( try { RegKey userKey; userKey.openKey(winvnc3, "Default"); - vlog.info("loading Default prefs"); + vlog.info("Loading default prefs"); LoadUserPrefs(userKey); - } catch(rdr::Exception& e) { - vlog.error("Error reading default settings:%s", e.str()); + } catch(std::exception& e) { - vlog.error("error reading Default settings:%s", e.what()); ++ vlog.error("Error reading Default settings:%s", e.what()); } // Open the local, user-specific settings @@@ -154,10 -154,10 +154,10 @@@ try { RegKey userKey; userKey.openKey(winvnc3, username.c_str()); - vlog.info("loading local User prefs"); + vlog.info("Loading local user prefs"); LoadUserPrefs(userKey); - } catch(rdr::Exception& e) { - vlog.error("Error reading local user settings:%s", e.str()); + } catch(std::exception& e) { - vlog.error("error reading local User settings:%s", e.what()); ++ vlog.error("Error reading local User settings:%s", e.what()); } // Open the user's own settings @@@ -165,10 -165,10 +165,10 @@@ try { RegKey userKey; userKey.openKey(HKEY_CURRENT_USER, "Software\\ORL\\WinVNC3"); - vlog.info("loading global User prefs"); + vlog.info("Loading global user prefs"); LoadUserPrefs(userKey); - } catch(rdr::Exception& e) { - vlog.error("Error reading global user settings:%s", e.str()); + } catch(std::exception& e) { - vlog.error("error reading global User settings:%s", e.what()); ++ vlog.error("Error reading global User settings:%s", e.what()); } } }