]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Internal branch sync. Included in this change:
authorVMware, Inc <>
Tue, 29 Mar 2011 18:55:17 +0000 (11:55 -0700)
committerMarcelo Vanzin <mvanzin@vmware.com>
Tue, 29 Mar 2011 18:55:17 +0000 (11:55 -0700)
. DnD: avoid crashing when clipboard doesn't have UTF-8 data.

. changes in shared code that don't affect open-vm-tools functionality.

Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
open-vm-tools/lib/include/vm_version.h
open-vm-tools/services/plugins/dndcp/copyPasteUIX11.cpp
open-vm-tools/services/plugins/dndcp/copyPasteUIX11.h
open-vm-tools/services/plugins/dndcp/dnd/dndClipboard.c
open-vm-tools/services/plugins/dndcp/dndUIX11.cpp

index d33028663795d7c9a9bda6ac487f1a682fdac3d5..87372256faec820d1752164cc9ffe8d72ce1a5a6 100644 (file)
@@ -83,7 +83,7 @@
  * hard-coded value for every other product.
  */
 #if defined(VMX86_DESKTOP)
-   #define PRODUCT_VERSION    7,0,0,PRODUCT_BUILD_NUMBER_NUMERIC  /* WORKSTATION_VERSION_NUMBER below has to match this */
+   #define PRODUCT_VERSION    8,0,0,PRODUCT_BUILD_NUMBER_NUMERIC  /* WORKSTATION_VERSION_NUMBER below has to match this */
 #elif defined(VMX86_TOOLS)
    #define PRODUCT_VERSION    TOOLS_VERSION_EXT_CURRENT_CSV
 #elif defined(VMX86_VCB)
@@ -94,7 +94,7 @@
    /* this should be kept in sync with the corresponding vpx branch. */
    #define PRODUCT_VERSION    5,0,0,PRODUCT_BUILD_NUMBER_NUMERIC
 #else
-   #define PRODUCT_VERSION    3,1,0,PRODUCT_BUILD_NUMBER_NUMERIC  /* PLAYER_VERSION_NUMBER below has to match this */
+   #define PRODUCT_VERSION    4,0,0,PRODUCT_BUILD_NUMBER_NUMERIC  /* PLAYER_VERSION_NUMBER below has to match this */
 #endif
 
 /*
 #define ESX_RELEASE ESX_RELEASE_UPDATE "." ESX_RELEASE_PATCH
 #define GSX_VERSION "e.x.p"
 #define VMSERVER_VERSION "e.x.p"
-#define WORKSTATION_VERSION_NUMBER "7.1.0" /* this version number should always match real WS version number */
+#define WORKSTATION_VERSION_NUMBER "8.0.0" /* this version number should always match real WS version number */
 #define WORKSTATION_VERSION "e.x.p"
 #define WORKSTATION_ENTERPRISE_VERSION "e.x.p"
 #define ACE_MANAGEMENT_SERVER_VERSION "e.x.p"
 #define CONSOLE_VERSION "4.1.0"
 #define P2V_VERSION "e.x.p"
 #define P2V_FILE_VERSION 3,0,0,0
-#define PLAYER_VERSION_NUMBER "3.1.0" /* this version number should always match real Player version number */
+#define PLAYER_VERSION_NUMBER "4.0.0" /* this version number should always match real Player version number */
 #define PLAYER_VERSION "e.x.p"
 #define V2V_VERSION "e.x.p"
 #define V2V_FILE_VERSION 1,0,0,0
 #define TOOLS_VERSION TOOLS_VERSION_CURRENT_STR
 
 #define USB_ARBITRATOR_VERSION_MAJOR 8
-#define USB_ARBITRATOR_VERSION_MINOR 2
-#define USB_ARBITRATOR_VERSION_Z     23
+#define USB_ARBITRATOR_VERSION_MINOR 3
+#define USB_ARBITRATOR_VERSION_Z     13
 
 #define USB_ARBITRATOR_VERSION_BASE  USB_ARBITRATOR_VERSION_MAJOR.\
                                      USB_ARBITRATOR_VERSION_MINOR
  * USB Arbitrator Component version. This version is used by the linux
  * installer. See USB_ARBITRATOR_COMPONENT_VERSION_NUMBER in mk/defs-onetime.mk
  */
-#define USB_ARBITRATOR_COMPONENT_VERSION_NUMBER "8.2.23"
+#define USB_ARBITRATOR_COMPONENT_VERSION_NUMBER "8.3.13"
 
 #ifdef VMX86_VPX
 #define VIM_API_TYPE "VirtualCenter"
index 97fbe95c0d0a8fb3d8b6b654bea4665790715793..82cd6790f8e01d7172b6169e8cee195affbd0107 100644 (file)
@@ -499,13 +499,13 @@ CopyPasteUIX11::LocalGetTextOrRTFRequestCB(Gtk::SelectionData& sd, // IN/OUT
 
    if (target == TARGET_NAME_APPLICATION_RTF ||
        target == TARGET_NAME_TEXT_RICHTEXT) {
-      if (0 == mHGRTFData.bytes()) {
+      if (0 == mHGRTFData.size()) {
          g_debug("%s: Can not get valid RTF data\n", __FUNCTION__);
          return;
       }
 
       g_debug("%s: providing RTF data, size %"FMTSZ"u\n",
-            __FUNCTION__, mHGRTFData.bytes());
+            __FUNCTION__, mHGRTFData.size());
 
       sd.set(target.c_str(), mHGRTFData.c_str());
    }
@@ -1129,6 +1129,22 @@ CopyPasteUIX11::GetRemoteClipboardCB(const CPClipboard *clip) // IN
        CPClipboard_ItemExists(clip, CPFORMAT_RTF)) {
       std::list<Gtk::TargetEntry> targets;
 
+      /*
+       * rtf should be first in the target list otherwise OpenOffice may not
+       * accept paste.
+       */
+      if (CPClipboard_GetItem(clip, CPFORMAT_RTF, &buf, &sz)) {
+         g_debug("%s: RTF data, size %"FMTSZ"u.\n", __FUNCTION__, sz);
+         Gtk::TargetEntry appRtf(TARGET_NAME_APPLICATION_RTF);
+         Gtk::TargetEntry textRtf(TARGET_NAME_TEXT_RICHTEXT);
+         Gtk::TargetEntry vmware(VMWARE_TARGET);
+
+         targets.push_back(appRtf);
+         targets.push_back(textRtf);
+         targets.push_back(vmware);
+         mHGRTFData = std::string((const char *)buf);
+      }
+
       if (CPClipboard_GetItem(clip, CPFORMAT_TEXT, &buf, &sz)) {
          Gtk::TargetEntry stringText(TARGET_NAME_STRING);
          Gtk::TargetEntry plainText(TARGET_NAME_TEXT_PLAIN);
@@ -1146,18 +1162,6 @@ CopyPasteUIX11::GetRemoteClipboardCB(const CPClipboard *clip) // IN
                                    STRING_ENCODING_UTF8);
       }
 
-      if (CPClipboard_GetItem(clip, CPFORMAT_RTF, &buf, &sz)) {
-         g_debug("%s: RTF data, size %"FMTSZ"u.\n", __FUNCTION__, sz);
-         Gtk::TargetEntry appRtf(TARGET_NAME_APPLICATION_RTF);
-         Gtk::TargetEntry textRtf(TARGET_NAME_TEXT_RICHTEXT);
-         Gtk::TargetEntry vmware(VMWARE_TARGET);
-
-         targets.push_back(appRtf);
-         targets.push_back(textRtf);
-         targets.push_back(vmware);
-         mHGRTFData = utf::string((const char *)buf);
-      }
-
       refClipboard->set(targets,
                         sigc::mem_fun(this, &CopyPasteUIX11::LocalGetTextOrRTFRequestCB),
                         sigc::mem_fun(this, &CopyPasteUIX11::LocalClearClipboardCB));
index 98e6250be6f0badf42a8d2c127c40707b674e3ba..a64a0d9feb4a5efcde5d2fdd4978fea13ba76b50 100644 (file)
@@ -111,7 +111,7 @@ private:
    utf::string mHGCopiedUriList;
    utf::utf8string mHGFCPData;
    utf::string mHGTextData;
-   utf::string mHGRTFData;
+   std::string mHGRTFData;
    std::vector<utf::string> mHGFileContentsList;
    bool mFileTransferDone;
    bool mBlockAdded;
index 113ceb64e5d2d2ff4e6c5e386d1396c412e5fcb0..9940362a785554daa123458888804e9c348902a8 100644 (file)
@@ -31,7 +31,7 @@
 #include "dndClipboard.h"
 #include "dndInt.h"
 #include "dndCPMsgV4.h"
-
+#include "unicode.h"
 
 #define CPFormatToIndex(x) ((unsigned int)(x) - 1)
 
@@ -270,6 +270,15 @@ CPClipboard_SetItem(CPClipboard *clip,          // IN/OUT: the clipboard
    item = &clip->items[CPFormatToIndex(fmt)];
 
    if (clipitem) {
+      /* It has to be valid utf8 for plain text format. */
+      if (CPFORMAT_TEXT == fmt) {
+         char *str = (char *)clipitem;
+         if (!Unicode_IsBufferValid(str,
+                                    strlen(str),
+                                    STRING_ENCODING_UTF8)) {
+            return FALSE;
+         }
+      }
       newBuf = malloc(size);
       if (!newBuf) {
          return FALSE;
@@ -368,6 +377,8 @@ CPClipboard_GetItem(const CPClipboard *clip,    // IN: the clipboard
    if (clip->items[CPFormatToIndex(fmt)].exists) {
       *buf = clip->items[CPFormatToIndex(fmt)].buf;
       *size = clip->items[CPFormatToIndex(fmt)].size;
+      ASSERT(*buf);
+      ASSERT((*size > 0) && (*size < CPCLIPITEM_MAX_SIZE_V3));
       return TRUE;
    } else {
       ASSERT(!clip->items[CPFormatToIndex(fmt)].size);
index 0dff137ce450220718b5923440f3965710a7b887..d9525cb99c3607ee1b4a085b0d5a3fcc0a1e3b73 100644 (file)
@@ -759,7 +759,10 @@ DnDUIX11::GtkDestDragMotionCB(const Glib::RefPtr<Gdk::DragContext> &dc,
          m_GHDnDInProgress = true;
          /* only begin drag enter after we get the data */
          /* Need to grab all of the data. */
-         ASSERT(RequestData(dc, timeValue));
+         if (!RequestData(dc, timeValue)) {
+            g_debug("%s: RequestData failed.\n", __FUNCTION__);
+            return false;
+         }
       } else {
          g_debug("%s: Multiple drag motions before gh data has been received.\n",
                __FUNCTION__);
@@ -1234,12 +1237,12 @@ DnDUIX11::SetCPClipboardFromGtk(const Gtk::SelectionData& sd) // IN
        target == TARGET_NAME_TEXT_PLAIN ||
        target == TARGET_NAME_UTF8_STRING ||
        target == TARGET_NAME_COMPOUND_TEXT)) {
-      utf::string source = sd.get_data_as_string().c_str();
-      if (source.bytes() > 0 &&
-          source.bytes() < DNDMSG_MAX_ARGSZ &&
+      std::string source = sd.get_data_as_string();
+      if (source.size() > 0 &&
+          source.size() < DNDMSG_MAX_ARGSZ &&
           CPClipboard_SetItem(&m_clipboard, CPFORMAT_TEXT, source.c_str(),
-                              source.bytes() + 1)) {
-         g_debug("%s: Got text, size %"FMTSZ"u\n", __FUNCTION__, source.bytes());
+                              source.size() + 1)) {
+         g_debug("%s: Got text, size %"FMTSZ"u\n", __FUNCTION__, source.size());
       } else {
          g_debug("%s: Failed to get text\n", __FUNCTION__);
          return false;
@@ -1251,12 +1254,12 @@ DnDUIX11::SetCPClipboardFromGtk(const Gtk::SelectionData& sd) // IN
    if (m_DnD->CheckCapability(DND_CP_CAP_RTF_DND) && (
        target == TARGET_NAME_APPLICATION_RTF ||
        target == TARGET_NAME_TEXT_RICHTEXT)) {
-      utf::string source = sd.get_data_as_string().c_str();
-      if (source.bytes() > 0 &&
-          source.bytes() < DNDMSG_MAX_ARGSZ &&
+      std::string source = sd.get_data_as_string();
+      if (source.size() > 0 &&
+          source.size() < DNDMSG_MAX_ARGSZ &&
           CPClipboard_SetItem(&m_clipboard, CPFORMAT_RTF, source.c_str(),
-                              source.bytes() + 1)) {
-         g_debug("%s: Got RTF, size %"FMTSZ"u\n", __FUNCTION__, source.bytes());
+                              source.size() + 1)) {
+         g_debug("%s: Got RTF, size %"FMTSZ"u\n", __FUNCTION__, source.size());
          return true;
       } else {
          g_debug("%s: Failed to get text\n", __FUNCTION__ );
@@ -1301,9 +1304,9 @@ DnDUIX11::RequestData(const Glib::RefPtr<Gdk::DragContext> &dc,
    }
 
    /* Then check plain text. */
+   targets->add(Glib::ustring(TARGET_NAME_UTF8_STRING));
    targets->add(Glib::ustring(TARGET_NAME_STRING));
    targets->add(Glib::ustring(TARGET_NAME_TEXT_PLAIN));
-   targets->add(Glib::ustring(TARGET_NAME_UTF8_STRING));
    targets->add(Glib::ustring(TARGET_NAME_COMPOUND_TEXT));
    target = m_detWnd->drag_dest_find_target(dc, targets);
    targets->remove(Glib::ustring(TARGET_NAME_STRING));