From: VMware, Inc <> Date: Tue, 19 Oct 2010 18:53:20 +0000 (-0700) Subject: Extra char at the end on text more than 64K to Linux VM X-Git-Tag: 2010.10.18-313025~67 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=447be025a0ec99f0b210747a99a4a19a8b6dad2f;p=thirdparty%2Fopen-vm-tools.git Extra char at the end on text more than 64K to Linux VM 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 --- diff --git a/open-vm-tools/services/plugins/dndcp/copyPasteCompatX11.c b/open-vm-tools/services/plugins/dndcp/copyPasteCompatX11.c index 908bf717d..b26ade546 100644 --- a/open-vm-tools/services/plugins/dndcp/copyPasteCompatX11.c +++ b/open-vm-tools/services/plugins/dndcp/copyPasteCompatX11.c @@ -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,