From ad8609a2ed4e37dfc1a03f529a45bfe685041da5 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Thu, 26 Apr 2012 09:04:14 +0000 Subject: [PATCH] Fix unsafe usage of the logging functions. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4905 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- common/rfb/CConnection.cxx | 2 +- common/rfb/CSecurityTLS.cxx | 2 +- common/rfb/SConnection.cxx | 2 +- common/rfb/SSecurityTLS.cxx | 2 +- unix/vncconfig/vncconfig.cxx | 2 +- unix/x0vncserver/x0vncserver.cxx | 2 +- vncviewer/CConn.cxx | 6 +++--- vncviewer/Viewport.cxx | 12 ++++++------ win/rfb_win32/CleanDesktop.cxx | 16 ++++++++-------- win/rfb_win32/Clipboard.cxx | 2 +- win/rfb_win32/DeviceFrameBuffer.cxx | 2 +- win/rfb_win32/MonitorInfo.cxx | 4 ++-- win/rfb_win32/RegConfig.cxx | 4 ++-- win/rfb_win32/SDisplay.cxx | 4 ++-- win/rfb_win32/SocketManager.cxx | 6 +++--- 15 files changed, 34 insertions(+), 34 deletions(-) diff --git a/common/rfb/CConnection.cxx b/common/rfb/CConnection.cxx index f2f19ca7..e73b02e6 100644 --- a/common/rfb/CConnection.cxx +++ b/common/rfb/CConnection.cxx @@ -100,7 +100,7 @@ void CConnection::processVersionMsg() char msg[256]; sprintf(msg,"Server gave unsupported RFB protocol version %d.%d", cp.majorVersion, cp.minorVersion); - vlog.error(msg); + vlog.error("%s", msg); state_ = RFBSTATE_INVALID; throw Exception(msg); } else if (useProtocol3_3 || cp.beforeVersion(3,7)) { diff --git a/common/rfb/CSecurityTLS.cxx b/common/rfb/CSecurityTLS.cxx index 3421de5e..6b6b017c 100644 --- a/common/rfb/CSecurityTLS.cxx +++ b/common/rfb/CSecurityTLS.cxx @@ -72,7 +72,7 @@ static LogWriter vlog_raw("RawTLS"); static void debug_log(int level, const char* str) { - vlog_raw.debug(str); + vlog_raw.debug("[%d]: %s", level, str); } void CSecurityTLS::initGlobal() diff --git a/common/rfb/SConnection.cxx b/common/rfb/SConnection.cxx index 941d30a1..ee573365 100644 --- a/common/rfb/SConnection.cxx +++ b/common/rfb/SConnection.cxx @@ -239,7 +239,7 @@ void SConnection::processInitMsg() void SConnection::throwConnFailedException(const char* msg) { - vlog.info(msg); + vlog.info("%s", msg); if (state_ == RFBSTATE_PROTOCOL_VERSION) { if (cp.majorVersion == 3 && cp.minorVersion == 3) { os->writeU32(0); diff --git a/common/rfb/SSecurityTLS.cxx b/common/rfb/SSecurityTLS.cxx index 2ea84e07..9a34f3a7 100644 --- a/common/rfb/SSecurityTLS.cxx +++ b/common/rfb/SSecurityTLS.cxx @@ -49,7 +49,7 @@ static LogWriter vlog_raw("RawTLS"); static void debug_log(int level, const char* str) { - vlog.debug(str); + vlog.debug("[%d]: %s", level, str); } void SSecurityTLS::initGlobal() diff --git a/unix/vncconfig/vncconfig.cxx b/unix/vncconfig/vncconfig.cxx index c901d193..f70cc714 100644 --- a/unix/vncconfig/vncconfig.cxx +++ b/unix/vncconfig/vncconfig.cxx @@ -431,7 +431,7 @@ int main(int argc, char** argv) XCloseDisplay(dpy); } catch (rdr::Exception &e) { - vlog.error(e.str()); + vlog.error("%s", e.str()); } return 0; diff --git a/unix/x0vncserver/x0vncserver.cxx b/unix/x0vncserver/x0vncserver.cxx index 64fbe683..b5498e18 100644 --- a/unix/x0vncserver/x0vncserver.cxx +++ b/unix/x0vncserver/x0vncserver.cxx @@ -546,7 +546,7 @@ int main(int argc, char** argv) } } catch (rdr::Exception &e) { - vlog.error(e.str()); + vlog.error("%s", e.str()); return 1; } diff --git a/vncviewer/CConn.cxx b/vncviewer/CConn.cxx index 12ebbe49..405cd979 100644 --- a/vncviewer/CConn.cxx +++ b/vncviewer/CConn.cxx @@ -99,7 +99,7 @@ CConn::CConn(const char* vncServerName) sock = new network::TcpSocket(serverHost, serverPort); vlog.info(_("connected to host %s port %d"), serverHost, serverPort); } catch (rdr::Exception& e) { - vlog.error(e.str()); + vlog.error("%s", e.str()); fl_alert("%s", e.str()); exit_vncviewer(); return; @@ -210,10 +210,10 @@ void CConn::socketEvent(int fd, void *data) cc->processMsg(); } while (cc->sock->inStream().checkNoWait(1)); } catch (rdr::EndOfStream& e) { - vlog.info(e.str()); + vlog.info("%s", e.str()); exit_vncviewer(); } catch (rdr::Exception& e) { - vlog.error(e.str()); + vlog.error("%s", e.str()); exit_vncviewer(e.str()); } diff --git a/vncviewer/Viewport.cxx b/vncviewer/Viewport.cxx index 1588f274..65dcfb20 100644 --- a/vncviewer/Viewport.cxx +++ b/vncviewer/Viewport.cxx @@ -369,7 +369,7 @@ int Viewport::handle(int event) try { cc->writer()->clientCutText(buffer, ret); } catch (rdr::Exception& e) { - vlog.error(e.str()); + vlog.error("%s", e.str()); exit_vncviewer(e.str()); } @@ -501,7 +501,7 @@ void Viewport::handlePointerEvent(const rfb::Point& pos, int buttonMask) try { cc->writer()->pointerEvent(pos, buttonMask); } catch (rdr::Exception& e) { - vlog.error(e.str()); + vlog.error("%s", e.str()); exit_vncviewer(e.str()); } } else { @@ -524,7 +524,7 @@ void Viewport::handlePointerTimeout(void *data) try { self->cc->writer()->pointerEvent(self->lastPointerPos, self->lastButtonMask); } catch (rdr::Exception& e) { - vlog.error(e.str()); + vlog.error("%s", e.str()); exit_vncviewer(e.str()); } } @@ -756,7 +756,7 @@ void Viewport::handleKeyEvent(int keyCode, int origKeyCode, const char *keyText, try { cc->writer()->keyEvent(iter->second, false); } catch (rdr::Exception& e) { - vlog.error(e.str()); + vlog.error("%s", e.str()); exit_vncviewer(e.str()); } @@ -800,7 +800,7 @@ void Viewport::handleKeyEvent(int keyCode, int origKeyCode, const char *keyText, if (downKeySym.find(FL_Alt_R) != downKeySym.end()) cc->writer()->keyEvent(XK_Alt_R, false); } catch (rdr::Exception& e) { - vlog.error(e.str()); + vlog.error("%s", e.str()); exit_vncviewer(e.str()); } } @@ -814,7 +814,7 @@ void Viewport::handleKeyEvent(int keyCode, int origKeyCode, const char *keyText, try { cc->writer()->keyEvent(keySym, down); } catch (rdr::Exception& e) { - vlog.error(e.str()); + vlog.error("%s", e.str()); exit_vncviewer(e.str()); } diff --git a/win/rfb_win32/CleanDesktop.cxx b/win/rfb_win32/CleanDesktop.cxx index 43252f10..52dc6bd7 100644 --- a/win/rfb_win32/CleanDesktop.cxx +++ b/win/rfb_win32/CleanDesktop.cxx @@ -178,7 +178,7 @@ void CleanDesktop::disableWallpaper() { if (ad.enable(false)) restoreActiveDesktop = true; } catch (rdr::Exception& e) { - vlog.error(e.str()); + vlog.error("%s", e.str()); } // -=- Switch of normal wallpaper and notify apps @@ -186,7 +186,7 @@ void CleanDesktop::disableWallpaper() { restoreWallpaper = true; } catch (rdr::Exception& e) { - vlog.info(e.str()); + vlog.info("%s", e.str()); } } @@ -203,7 +203,7 @@ void CleanDesktop::enableWallpaper() { ad.enable(true); restoreActiveDesktop = false; } catch (rdr::Exception& e) { - vlog.error(e.str()); + vlog.error("%s", e.str()); } } @@ -216,7 +216,7 @@ void CleanDesktop::enableWallpaper() { } } catch (rdr::Exception& e) { - vlog.info(e.str()); + vlog.info("%s", e.str()); } } @@ -230,7 +230,7 @@ void CleanDesktop::disablePattern() { restorePattern = true; } catch (rdr::Exception& e) { - vlog.info(e.str()); + vlog.info("%s", e.str()); } } @@ -252,7 +252,7 @@ void CleanDesktop::enablePattern() { } } catch (rdr::Exception& e) { - vlog.info(e.str()); + vlog.info("%s", e.str()); } } @@ -288,7 +288,7 @@ void CleanDesktop::disableEffects() { restoreEffects = true; } catch (rdr::Exception& e) { - vlog.info(e.str()); + vlog.info("%s", e.str()); } } @@ -317,6 +317,6 @@ void CleanDesktop::enableEffects() { } } catch (rdr::Exception& e) { - vlog.info(e.str()); + vlog.info("%s", e.str()); } } diff --git a/win/rfb_win32/Clipboard.cxx b/win/rfb_win32/Clipboard.cxx index a4c43f04..482519e7 100644 --- a/win/rfb_win32/Clipboard.cxx +++ b/win/rfb_win32/Clipboard.cxx @@ -185,7 +185,7 @@ Clipboard::setClipText(const char* text) { vlog.debug("set clipboard"); } catch (rdr::Exception& e) { - vlog.debug(e.str()); + vlog.debug("%s", e.str()); } // - Close the clipboard diff --git a/win/rfb_win32/DeviceFrameBuffer.cxx b/win/rfb_win32/DeviceFrameBuffer.cxx index 921e1fa5..cc9bbcad 100644 --- a/win/rfb_win32/DeviceFrameBuffer.cxx +++ b/win/rfb_win32/DeviceFrameBuffer.cxx @@ -276,7 +276,7 @@ void DeviceFrameBuffer::setCursor(HCURSOR hCursor, VNCServer* server) server->setCursor(cursor.width(), cursor.height(), cursor.hotspot, cursorBm.data, cursor.mask.buf); } catch (rdr::Exception& e) { - vlog.error(e.str()); + vlog.error("%s", e.str()); } } diff --git a/win/rfb_win32/MonitorInfo.cxx b/win/rfb_win32/MonitorInfo.cxx index 0a5e34fa..c57cd26c 100644 --- a/win/rfb_win32/MonitorInfo.cxx +++ b/win/rfb_win32/MonitorInfo.cxx @@ -80,7 +80,7 @@ MonitorInfo::MonitorInfo(HWND window) { return; } } catch (rdr::Exception& e) { - vlog.error(e.str()); + vlog.error("%s", e.str()); } #endif @@ -106,7 +106,7 @@ MonitorInfo::MonitorInfo(const RECT& r) { return; } } catch (rdr::Exception& e) { - vlog.error(e.str()); + vlog.error("%s", e.str()); } #endif diff --git a/win/rfb_win32/RegConfig.cxx b/win/rfb_win32/RegConfig.cxx index 90980c33..30cb3102 100644 --- a/win/rfb_win32/RegConfig.cxx +++ b/win/rfb_win32/RegConfig.cxx @@ -48,7 +48,7 @@ bool RegConfig::setKey(const HKEY rootkey, const TCHAR* keyname) { processEvent(event); return true; } catch (rdr::Exception& e) { - vlog.debug(e.str()); + vlog.debug("%s", e.str()); return false; } } @@ -65,7 +65,7 @@ void RegConfig::loadRegistryConfig(RegKey& key) { } } catch (rdr::SystemException& e) { if (e.err != 6) - vlog.error(e.str()); + vlog.error("%s", e.str()); } } diff --git a/win/rfb_win32/SDisplay.cxx b/win/rfb_win32/SDisplay.cxx index 583b4aba..6d0c924f 100644 --- a/win/rfb_win32/SDisplay.cxx +++ b/win/rfb_win32/SDisplay.cxx @@ -185,7 +185,7 @@ void SDisplay::startCore() { if (tryMethod == 0) throw rdr::Exception("unable to access desktop"); tryMethod--; - vlog.error(e.str()); + vlog.error("%s", e.str()); } } vlog.info("Started %s", core->methodName()); @@ -388,7 +388,7 @@ SDisplay::processEvent(HANDLE event) { try { core->flushUpdates(); } catch (rdr::Exception& e) { - vlog.error(e.str()); + vlog.error("%s", e.str()); restartCore(); return; } diff --git a/win/rfb_win32/SocketManager.cxx b/win/rfb_win32/SocketManager.cxx index 9a0dab4c..d4f1965a 100644 --- a/win/rfb_win32/SocketManager.cxx +++ b/win/rfb_win32/SocketManager.cxx @@ -43,7 +43,7 @@ static void requestAddressChangeEvents(network::SocketListener* sock_) { if (WSAIoctl(sock_->getFd(), SIO_ADDRESS_LIST_CHANGE, 0, 0, 0, 0, &dummy, 0, 0) == SOCKET_ERROR) { DWORD err = WSAGetLastError(); if (err != WSAEWOULDBLOCK) - vlog.error("Unable to track address changes", err); + vlog.error("Unable to track address changes: 0x%08x", (unsigned)err); } } @@ -70,7 +70,7 @@ void SocketManager::addListener(network::SocketListener* sock_, if (event) WSACloseEvent(event); delete sock_; - vlog.error(e.str()); + vlog.error("%s", e.str()); throw; } @@ -204,7 +204,7 @@ void SocketManager::processEvent(HANDLE event) { if (WSAEventSelect(ci.sock->getFd(), event, FD_READ | FD_CLOSE) == SOCKET_ERROR) throw rdr::SystemException("unable to re-enable WSAEventSelect:%u", WSAGetLastError()); } catch (rdr::Exception& e) { - vlog.error(e.str()); + vlog.error("%s", e.str()); remSocket(ci.sock); } } -- 2.39.5