From 03502b36edbd2390c8b93edcc6b5f57299977578 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 2 Mar 2021 22:14:52 +0100 Subject: 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(-) (limited to 'nx-X11/programs') 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 } -- cgit v1.2.3