]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Extra char at the end on text more than 64K to Linux VM
authorVMware, Inc <>
Tue, 19 Oct 2010 18:53:20 +0000 (11:53 -0700)
committerMarcelo Vanzin <mvanzin@vmware.com>
Tue, 19 Oct 2010 18:53:20 +0000 (11:53 -0700)
The reason is that the NULL terminator may be missing in this case.
The fix is to always add NULL terminator to end of clipboard buffer.

Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
open-vm-tools/services/plugins/dndcp/copyPasteCompatX11.c

index 908bf717d701ddfb85238e34d24c730695ac6843..b26ade5467656c1ccb6ebfe00e6420e084fb2e89 100644 (file)
@@ -100,7 +100,7 @@ static char gGuestSelPrimaryBuf[MAX_SELECTION_BUFFER_LENGTH];
 static char gGuestSelClipboardBuf[MAX_SELECTION_BUFFER_LENGTH];
 static uint64 gGuestSelPrimaryTime = 0;
 static uint64 gGuestSelClipboardTime = 0;
-static char gHostClipboardBuf[MAX_SELECTION_BUFFER_LENGTH];
+static char gHostClipboardBuf[MAX_SELECTION_BUFFER_LENGTH + 1];
 
 static Bool gIsOwner;
 static ToolsAppCtx *gCtx = NULL;
@@ -660,11 +660,11 @@ CopyPaste_GetBackdoorSelections(void)
    }
 
    selLength = GuestApp_GetHostSelectionLen();
-   if (selLength < 0) {
+   if (selLength < 0 || selLength > MAX_SELECTION_BUFFER_LENGTH) {
       return FALSE;
    } else if (selLength > 0) {
-      memset(gHostClipboardBuf, 0, sizeof (gHostClipboardBuf));
       GuestApp_GetHostSelection(selLength, gHostClipboardBuf);
+      gHostClipboardBuf[selLength] = 0;
       g_debug("CopyPaste_GetBackdoorSelections Get text [%s].\n", gHostClipboardBuf);
       gtk_selection_owner_set(gUserMainWidget,
                               GDK_SELECTION_CLIPBOARD,