[X2Go-Commits] [nx-libs] 389/429: Clipboard.c: print clipboard content only on explicit request

git-admin at x2go.org git-admin at x2go.org
Mon Oct 18 09:37:13 CEST 2021


This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch 3.6.x
in repository nx-libs.

commit 03502b36edbd2390c8b93edcc6b5f57299977578
Author: Ulrich Sibiller <uli42 at gmx.de>
Date:   Tue Mar 2 22:14:52 2021 +0100

    Clipboard.c: print clipboard content only on explicit request
    
    This helps making people aware that their debug logs might contain
    sensible information.
---
 nx-X11/programs/Xserver/hw/nxagent/Clipboard.c | 46 ++++++++++++++++++++------
 1 file changed, 36 insertions(+), 10 deletions(-)

diff --git a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c
index 4bdd32e8f..27aa49578 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c
@@ -59,6 +59,13 @@
 #undef  TEST
 #undef  DEBUG
 
+/*
+ * define this to see the clipboard content in the debug output. As
+ * this can lead to information leaking it must be activated
+ * explicitly!
+ */
+#undef PRINT_CLIPBOARD_CONTENT_ON_DEBUG
+
 /*
  * Define these to also support special targets TEXT and COMPOUND_TEXT
  * in text-only mode. We do not have a special handling for these. See
@@ -432,6 +439,11 @@ void nxagentDumpClipboardStat(void)
   fprintf(stderr, "  serverLastRequestedSelection           [% 4ld][%s]\n", serverLastRequestedSelection, NameForRemAtom(serverLastRequestedSelection));
 
   fprintf(stderr, "Compile time settings\n");
+#ifdef PRINT_CLIPBOARD_CONTENT_ON_DEBUG
+  fprintf(stderr, "  PRINT_CLIPBOARD_CONTENT_ON_DEBUG       [enabled]\n");
+#else
+  fprintf(stderr, "  PRINT_CLIPBOARD_CONTENT_ON_DEBUG       [disabled]\n");
+#endif
 #ifdef SUPPORT_TEXT_TARGET
   fprintf(stderr, "  SUPPORT_TEXT_TARGET                    [enabled]\n");
 #else
@@ -1771,12 +1783,19 @@ Bool nxagentCollectPropertyEventFromXServer(int resource)
                                  ulReturnItems, pszReturnData, 1);
 
             #ifdef DEBUG
-            fprintf(stderr, "%s: Selection property [%d][%s] changed to [\"%*.*s\"...]\n", __func__,
-                        lastClients[index].property,
-                            validateString(NameForIntAtom(lastClients[index].property)),
-                                (int)(min(20, ulReturnItems * resultFormat / 8)),
-                                    (int)(min(20, ulReturnItems * resultFormat / 8)),
-                                        pszReturnData);
+            fprintf(stderr, "%s: Selection property [%d][%s] changed to"
+                    #ifdef PRINT_CLIPBOARD_CONTENT_ON_DEBUG
+                    "[\"%*.*s\"...]"
+                    #endif
+                    "\n", __func__,
+                    lastClients[index].property,
+                    validateString(NameForIntAtom(lastClients[index].property))
+                    #ifdef PRINT_CLIPBOARD_CONTENT_ON_DEBUG
+                    ,(int)(min(20, ulReturnItems * resultFormat / 8)),
+                    (int)(min(20, ulReturnItems * resultFormat / 8)),
+                    pszReturnData
+                    #endif
+                   );
             #endif
 
             endTransfer(index, SELECTION_SUCCESS);
@@ -2033,15 +2052,22 @@ void handlePropertyTransferFromAgentToXserver(int index, XlibAtom property)
                           ulReturnItems);
           #ifdef DEBUG
           {
-            fprintf(stderr, "%s: XChangeProperty sent to window [0x%lx] for property [%ld][%s] len [%d] value [\"%*.*s\"...]\n",
+            fprintf(stderr, "%s: XChangeProperty sent to window [0x%lx] for property [%ld][%s] len [%d]"
+                    #ifdef PRINT_CLIPBOARD_CONTENT_ON_DEBUG
+		    "value [\"%*.*s\"...]"
+                    #endif
+		    "\n",
                     __func__,
                     lastServers[index].requestor,
                     lastServers[index].property,
                     NameForRemAtom(lastServers[index].property),
-                    (int)ulReturnItems * 8 / 8,
-                    (int)(min(20, ulReturnItems * 8 / 8)),
+                    (int)ulReturnItems * 8 / 8
+                    #ifdef PRINT_CLIPBOARD_CONTENT_ON_DEBUG
+                    ,(int)(min(20, ulReturnItems * 8 / 8)),
                     (int)(min(20, ulReturnItems * 8 / 8)),
-                    pszReturnData);
+                    pszReturnData
+                    #endif
+		    );
           }
           #endif
         }

--
Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/nx-libs.git


More information about the x2go-commits mailing list