Revision: 4905
          http://tigervnc.svn.sourceforge.net/tigervnc/?rev=4905&view=rev
Author:   ossman_
Date:     2012-04-26 09:04:14 +0000 (Thu, 26 Apr 2012)
Log Message:
-----------
Fix unsafe usage of the logging functions.

Modified Paths:
--------------
    trunk/common/rfb/CConnection.cxx
    trunk/common/rfb/CSecurityTLS.cxx
    trunk/common/rfb/SConnection.cxx
    trunk/common/rfb/SSecurityTLS.cxx
    trunk/unix/vncconfig/vncconfig.cxx
    trunk/unix/x0vncserver/x0vncserver.cxx
    trunk/vncviewer/CConn.cxx
    trunk/vncviewer/Viewport.cxx
    trunk/win/rfb_win32/CleanDesktop.cxx
    trunk/win/rfb_win32/Clipboard.cxx
    trunk/win/rfb_win32/DeviceFrameBuffer.cxx
    trunk/win/rfb_win32/MonitorInfo.cxx
    trunk/win/rfb_win32/RegConfig.cxx
    trunk/win/rfb_win32/SDisplay.cxx
    trunk/win/rfb_win32/SocketManager.cxx

Modified: trunk/common/rfb/CConnection.cxx
===================================================================
--- trunk/common/rfb/CConnection.cxx    2012-04-26 08:51:19 UTC (rev 4904)
+++ trunk/common/rfb/CConnection.cxx    2012-04-26 09:04:14 UTC (rev 4905)
@@ -100,7 +100,7 @@
     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)) {

Modified: trunk/common/rfb/CSecurityTLS.cxx
===================================================================
--- trunk/common/rfb/CSecurityTLS.cxx   2012-04-26 08:51:19 UTC (rev 4904)
+++ trunk/common/rfb/CSecurityTLS.cxx   2012-04-26 09:04:14 UTC (rev 4905)
@@ -72,7 +72,7 @@
 
 static void debug_log(int level, const char* str)
 {
-  vlog_raw.debug(str);
+  vlog_raw.debug("[%d]: %s", level, str);
 }
 
 void CSecurityTLS::initGlobal()

Modified: trunk/common/rfb/SConnection.cxx
===================================================================
--- trunk/common/rfb/SConnection.cxx    2012-04-26 08:51:19 UTC (rev 4904)
+++ trunk/common/rfb/SConnection.cxx    2012-04-26 09:04:14 UTC (rev 4905)
@@ -239,7 +239,7 @@
 
 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);

Modified: trunk/common/rfb/SSecurityTLS.cxx
===================================================================
--- trunk/common/rfb/SSecurityTLS.cxx   2012-04-26 08:51:19 UTC (rev 4904)
+++ trunk/common/rfb/SSecurityTLS.cxx   2012-04-26 09:04:14 UTC (rev 4905)
@@ -49,7 +49,7 @@
 
 static void debug_log(int level, const char* str)
 {
-  vlog.debug(str);
+  vlog.debug("[%d]: %s", level, str);
 }
 
 void SSecurityTLS::initGlobal()

Modified: trunk/unix/vncconfig/vncconfig.cxx
===================================================================
--- trunk/unix/vncconfig/vncconfig.cxx  2012-04-26 08:51:19 UTC (rev 4904)
+++ trunk/unix/vncconfig/vncconfig.cxx  2012-04-26 09:04:14 UTC (rev 4905)
@@ -431,7 +431,7 @@
     XCloseDisplay(dpy);
 
   } catch (rdr::Exception &e) {
-    vlog.error(e.str());
+    vlog.error("%s", e.str());
   }
 
   return 0;

Modified: trunk/unix/x0vncserver/x0vncserver.cxx
===================================================================
--- trunk/unix/x0vncserver/x0vncserver.cxx      2012-04-26 08:51:19 UTC (rev 
4904)
+++ trunk/unix/x0vncserver/x0vncserver.cxx      2012-04-26 09:04:14 UTC (rev 
4905)
@@ -546,7 +546,7 @@
     }
 
   } catch (rdr::Exception &e) {
-    vlog.error(e.str());
+    vlog.error("%s", e.str());
     return 1;
   }
 

Modified: trunk/vncviewer/CConn.cxx
===================================================================
--- trunk/vncviewer/CConn.cxx   2012-04-26 08:51:19 UTC (rev 4904)
+++ trunk/vncviewer/CConn.cxx   2012-04-26 09:04:14 UTC (rev 4905)
@@ -99,7 +99,7 @@
     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 @@
       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());
   }
 

Modified: trunk/vncviewer/Viewport.cxx
===================================================================
--- trunk/vncviewer/Viewport.cxx        2012-04-26 08:51:19 UTC (rev 4904)
+++ trunk/vncviewer/Viewport.cxx        2012-04-26 09:04:14 UTC (rev 4905)
@@ -369,7 +369,7 @@
     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 @@
       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 @@
   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 @@
     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 @@
       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 @@
   try {
     cc->writer()->keyEvent(keySym, down);
   } catch (rdr::Exception& e) {
-    vlog.error(e.str());
+    vlog.error("%s", e.str());
     exit_vncviewer(e.str());
   }
 

Modified: trunk/win/rfb_win32/CleanDesktop.cxx
===================================================================
--- trunk/win/rfb_win32/CleanDesktop.cxx        2012-04-26 08:51:19 UTC (rev 
4904)
+++ trunk/win/rfb_win32/CleanDesktop.cxx        2012-04-26 09:04:14 UTC (rev 
4905)
@@ -178,7 +178,7 @@
       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 @@
     restoreWallpaper = true;
 
   } catch (rdr::Exception& e) {
-    vlog.info(e.str());
+    vlog.info("%s", e.str());
   }
 }
 
@@ -203,7 +203,7 @@
         ad.enable(true);
         restoreActiveDesktop = false;
       } catch (rdr::Exception& e) {
-        vlog.error(e.str());
+        vlog.error("%s", e.str());
       }
     }
 
@@ -216,7 +216,7 @@
     }
 
   } catch (rdr::Exception& e) {
-    vlog.info(e.str());
+    vlog.info("%s", e.str());
   }
 }
 
@@ -230,7 +230,7 @@
     restorePattern = true;
 
   } catch (rdr::Exception& e) {
-    vlog.info(e.str());
+    vlog.info("%s", e.str());
   }
 }
 
@@ -252,7 +252,7 @@
     }
 
   } catch (rdr::Exception& e) {
-    vlog.info(e.str());
+    vlog.info("%s", e.str());
   }
 }
 
@@ -288,7 +288,7 @@
     restoreEffects = true;
 
   } catch (rdr::Exception& e) {
-    vlog.info(e.str());
+    vlog.info("%s", e.str());
   }
 }
 
@@ -317,6 +317,6 @@
     }
 
   } catch (rdr::Exception& e) {
-    vlog.info(e.str());
+    vlog.info("%s", e.str());
   }
 }

Modified: trunk/win/rfb_win32/Clipboard.cxx
===================================================================
--- trunk/win/rfb_win32/Clipboard.cxx   2012-04-26 08:51:19 UTC (rev 4904)
+++ trunk/win/rfb_win32/Clipboard.cxx   2012-04-26 09:04:14 UTC (rev 4905)
@@ -185,7 +185,7 @@
 
     vlog.debug("set clipboard");
   } catch (rdr::Exception& e) {
-    vlog.debug(e.str());
+    vlog.debug("%s", e.str());
   }
 
   // - Close the clipboard

Modified: trunk/win/rfb_win32/DeviceFrameBuffer.cxx
===================================================================
--- trunk/win/rfb_win32/DeviceFrameBuffer.cxx   2012-04-26 08:51:19 UTC (rev 
4904)
+++ trunk/win/rfb_win32/DeviceFrameBuffer.cxx   2012-04-26 09:04:14 UTC (rev 
4905)
@@ -276,7 +276,7 @@
     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());
   }
 }
 

Modified: trunk/win/rfb_win32/MonitorInfo.cxx
===================================================================
--- trunk/win/rfb_win32/MonitorInfo.cxx 2012-04-26 08:51:19 UTC (rev 4904)
+++ trunk/win/rfb_win32/MonitorInfo.cxx 2012-04-26 09:04:14 UTC (rev 4905)
@@ -80,7 +80,7 @@
       return;
     }
   } catch (rdr::Exception& e) {
-    vlog.error(e.str());
+    vlog.error("%s", e.str());
   }
 #endif
 
@@ -106,7 +106,7 @@
       return;
     }
   } catch (rdr::Exception& e) {
-    vlog.error(e.str());
+    vlog.error("%s", e.str());
   }
 #endif
 

Modified: trunk/win/rfb_win32/RegConfig.cxx
===================================================================
--- trunk/win/rfb_win32/RegConfig.cxx   2012-04-26 08:51:19 UTC (rev 4904)
+++ trunk/win/rfb_win32/RegConfig.cxx   2012-04-26 09:04:14 UTC (rev 4905)
@@ -48,7 +48,7 @@
     processEvent(event);
     return true;
   } catch (rdr::Exception& e) {
-    vlog.debug(e.str());
+    vlog.debug("%s", e.str());
     return false;
   }
 }
@@ -65,7 +65,7 @@
     }
   } catch (rdr::SystemException& e) {
     if (e.err != 6)
-      vlog.error(e.str());
+      vlog.error("%s", e.str());
   }
 }
 

Modified: trunk/win/rfb_win32/SDisplay.cxx
===================================================================
--- trunk/win/rfb_win32/SDisplay.cxx    2012-04-26 08:51:19 UTC (rev 4904)
+++ trunk/win/rfb_win32/SDisplay.cxx    2012-04-26 09:04:14 UTC (rev 4905)
@@ -185,7 +185,7 @@
       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 @@
       try {
         core->flushUpdates();
       } catch (rdr::Exception& e) {
-        vlog.error(e.str());
+        vlog.error("%s", e.str());
         restartCore();
         return;
       }

Modified: trunk/win/rfb_win32/SocketManager.cxx
===================================================================
--- trunk/win/rfb_win32/SocketManager.cxx       2012-04-26 08:51:19 UTC (rev 
4904)
+++ trunk/win/rfb_win32/SocketManager.cxx       2012-04-26 09:04:14 UTC (rev 
4905)
@@ -43,7 +43,7 @@
   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 @@
     if (event)
       WSACloseEvent(event);
     delete sock_;
-    vlog.error(e.str());
+    vlog.error("%s", e.str());
     throw;
   }
 
@@ -204,7 +204,7 @@
       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);
     }
   }

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Tigervnc-commits mailing list
Tigervnc-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tigervnc-commits

Reply via email to