Revision: 4295
          http://tigervnc.svn.sourceforge.net/tigervnc/?rev=4295&view=rev
Author:   atkac
Date:     2011-02-18 10:54:11 +0000 (Fri, 18 Feb 2011)

Log Message:
-----------
[Bugfix] Register GNUTLS debug routines only when we actually need them.

Modified Paths:
--------------
    trunk/common/rfb/CSecurityTLS.cxx
    trunk/common/rfb/LogWriter.h
    trunk/common/rfb/SSecurityTLS.cxx

Modified: trunk/common/rfb/CSecurityTLS.cxx
===================================================================
--- trunk/common/rfb/CSecurityTLS.cxx   2011-02-18 05:42:10 UTC (rev 4294)
+++ trunk/common/rfb/CSecurityTLS.cxx   2011-02-18 10:54:11 UTC (rev 4295)
@@ -62,23 +62,18 @@
 #define WITHOUT_X509_TIMES
 #endif
 
-#define TLS_DEBUG
-
 using namespace rfb;
 
 StringParameter CSecurityTLS::x509ca("x509ca", "X509 CA certificate", "", 
ConfViewer);
 StringParameter CSecurityTLS::x509crl("x509crl", "X509 CRL file", "", 
ConfViewer);
 
 static LogWriter vlog("TLS");
+static LogWriter vlog_raw("RawTLS");
 
-#ifdef TLS_DEBUG
-static LogWriter vlog_raw("Raw TLS");
-
 static void debug_log(int level, const char* str)
 {
   vlog_raw.debug(str);
 }
-#endif
 
 void CSecurityTLS::initGlobal()
 {
@@ -87,10 +82,11 @@
   if (!globalInitDone) {
     gnutls_global_init();
 
-#ifdef TLS_DEBUG
-    gnutls_global_set_log_level(10);
-    gnutls_global_set_log_function(debug_log);
-#endif
+    /* 100 means debug log */
+    if (vlog_raw.getLevel() >= 100) {
+      gnutls_global_set_log_level(10);
+      gnutls_global_set_log_function(debug_log);
+    }
 
     globalInitDone = true;
   }

Modified: trunk/common/rfb/LogWriter.h
===================================================================
--- trunk/common/rfb/LogWriter.h        2011-02-18 05:42:10 UTC (rev 4294)
+++ trunk/common/rfb/LogWriter.h        2011-02-18 10:54:11 UTC (rev 4295)
@@ -51,6 +51,7 @@
 
     void setLog(Logger *logger);
     void setLevel(int level);
+    int getLevel(void) { return m_level; }
 
     inline void write(int level, const char* format, ...) {
       if (m_log && (level <= m_level)) {

Modified: trunk/common/rfb/SSecurityTLS.cxx
===================================================================
--- trunk/common/rfb/SSecurityTLS.cxx   2011-02-18 05:42:10 UTC (rev 4294)
+++ trunk/common/rfb/SSecurityTLS.cxx   2011-02-18 10:54:11 UTC (rev 4295)
@@ -35,7 +35,6 @@
 #include <rdr/TLSOutStream.h>
 
 #define DH_BITS 1024 /* XXX This should be configurable! */
-#define TLS_DEBUG
 
 using namespace rfb;
 
@@ -46,13 +45,12 @@
 ("x509key", "specifies path to the key of the x509 certificate in PEM format", 
"", ConfServer);
 
 static LogWriter vlog("TLS");
+static LogWriter vlog_raw("RawTLS");
 
-#ifdef TLS_DEBUG
 static void debug_log(int level, const char* str)
 {
   vlog.debug(str);
 }
-#endif
 
 void SSecurityTLS::initGlobal()
 {
@@ -62,10 +60,11 @@
     if (gnutls_global_init() != GNUTLS_E_SUCCESS)
       throw AuthFailureException("gnutls_global_init failed");
 
-#ifdef TLS_DEBUG
-    gnutls_global_set_log_level(10);
-    gnutls_global_set_log_function(debug_log);
-#endif
+    /* 100 means debug log */
+    if (vlog_raw.getLevel() >= 100) {
+      gnutls_global_set_log_level(10);
+      gnutls_global_set_log_function(debug_log);
+    }
 
     globalInitDone = true;
   }


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

------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Tigervnc-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tigervnc-commits

Reply via email to