Index: trunk/src/VBox/GuestHost/SharedClipboard/clipboard-x11.cpp
===================================================================
--- trunk/src/VBox/GuestHost/SharedClipboard/clipboard-x11.cpp	(revision 87072)
+++ trunk/src/VBox/GuestHost/SharedClipboard/clipboard-x11.cpp	(revision 87082)
@@ -1386,16 +1386,15 @@
 
 /**
- * This is a wrapper around ShClX11RequestDataForX11Callback that will cache the
- * data returned.
+ * Helper for ShClX11RequestDataForX11Callback() that will cache the data returned.
  *
  * @returns VBox status code. VERR_NO_DATA if no data available.
  * @param   pCtx                The X11 clipboard context to use.
- * @param   Format              Clipboard format to read data in.
- * @param   ppv                 Where to store the allocated read data on success.
- *                              Needs to be free'd by the caller.
- * @param   pcb                 Where to return the size (in bytes) of the allocated read data on success.
- */
-static int clipReadVBoxShCl(PSHCLX11CTX pCtx, SHCLFORMAT Format,
-                            void **ppv, uint32_t *pcb)
+ * @param   uFmt                Clipboard format to read data in.
+ * @param   ppv                 Returns an allocated buffer with data read on success.
+ *                              Needs to be free'd with RTMemFree() by the caller.
+ * @param   pcb                 Returns the amount of data read (in bytes) on success.
+ */
+static int shClX11RequestDataForX11CallbackHelper(PSHCLX11CTX pCtx, SHCLFORMAT uFmt,
+                                                  void **ppv, uint32_t *pcb)
 {
     AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
@@ -1403,5 +1402,5 @@
     AssertPtrReturn(pcb,  VERR_INVALID_POINTER);
 
-    LogFlowFunc(("pCtx=%p, Format=%02X\n", pCtx, Format));
+    LogFlowFunc(("pCtx=%p, uFmt=%#x\n", pCtx, uFmt));
 
     int rc = VINF_SUCCESS;
@@ -1410,8 +1409,8 @@
     uint32_t cb = 0;
 
-    if (Format == VBOX_SHCL_FMT_UNICODETEXT)
+    if (uFmt == VBOX_SHCL_FMT_UNICODETEXT)
     {
         if (pCtx->pvUnicodeCache == NULL) /** @todo r=andy Using string cache here? */
-            rc = ShClX11RequestDataForX11Callback(pCtx->pFrontend, Format,
+            rc = ShClX11RequestDataForX11Callback(pCtx->pFrontend, uFmt,
                                                   &pCtx->pvUnicodeCache,
                                                   &pCtx->cbUnicodeCache);
@@ -1429,5 +1428,14 @@
     else
     {
-        rc = ShClX11RequestDataForX11Callback(pCtx->pFrontend, Format, &pv, &cb);
+        rc = ShClX11RequestDataForX11Callback(pCtx->pFrontend, uFmt, &pv, &cb);
+    }
+
+
+    /* Safey net in case the callbacks above misbehave
+     * (must return VERR_NO_DATA if no data available). */
+    if (   RT_SUCCESS(rc)
+        && (pv == NULL || cb == 0))
+    {
+        rc = VERR_NO_DATA;
     }
 
@@ -1585,5 +1593,5 @@
                                 int *piFormatReturn)
 {
-    int rc = VINF_SUCCESS;
+    int rc = VERR_NOT_SUPPORTED; /* Play safe by default. */
 
     SHCLX11FMTIDX idxFmtX11 = clipFindX11FormatByAtom(pCtx, *atomTarget);
@@ -1601,13 +1609,13 @@
 #endif
 
-    if (   ((fmtX11 == SHCLX11FMT_UTF8) || (fmtX11 == SHCLX11FMT_TEXT))
+    void    *pv = NULL;
+    uint32_t cb = 0;
+
+    if (   (   (fmtX11 == SHCLX11FMT_UTF8)
+            || (fmtX11 == SHCLX11FMT_TEXT)
+           )
         && (pCtx->vboxFormats & VBOX_SHCL_FMT_UNICODETEXT))
     {
-        void    *pv = NULL;
-        uint32_t cb = 0;
-        rc = clipReadVBoxShCl(pCtx, VBOX_SHCL_FMT_UNICODETEXT, &pv, &cb);
-        if (RT_SUCCESS(rc) && (cb == 0))
-            rc = VERR_NO_DATA;
-
+        rc = shClX11RequestDataForX11CallbackHelper(pCtx, VBOX_SHCL_FMT_UNICODETEXT, &pv, &cb);
         if (   RT_SUCCESS(rc)
             && (   (fmtX11 == SHCLX11FMT_UTF8)
@@ -1628,17 +1636,12 @@
              && (pCtx->vboxFormats & VBOX_SHCL_FMT_BITMAP))
     {
-        void    *pv = NULL;
-        uint32_t cb = 0;
-        rc = clipReadVBoxShCl(pCtx, VBOX_SHCL_FMT_BITMAP, &pv, &cb);
-        if (RT_SUCCESS(rc) && (cb == 0))
-            rc = VERR_NO_DATA;
-        if (RT_SUCCESS(rc) && (fmtX11 == SHCLX11FMT_BMP))
-        {
-            /* Create a full BMP from it */
+        rc = shClX11RequestDataForX11CallbackHelper(pCtx, VBOX_SHCL_FMT_BITMAP, &pv, &cb);
+        if (   RT_SUCCESS(rc)
+            && (fmtX11 == SHCLX11FMT_BMP))
+        {
+            /* Create a full BMP from it. */
             rc = ShClDibToBmp(pv, cb, (void **)pValReturn,
                               (size_t *)pcLenReturn);
         }
-        else
-            rc = VERR_NOT_SUPPORTED;
 
         if (RT_SUCCESS(rc))
@@ -1653,9 +1656,5 @@
             && (pCtx->vboxFormats & VBOX_SHCL_FMT_HTML))
     {
-        void    *pv = NULL;
-        uint32_t cb = 0;
-        rc = clipReadVBoxShCl(pCtx, VBOX_SHCL_FMT_HTML, &pv, &cb);
-        if (RT_SUCCESS(rc) && (cb == 0))
-            rc = VERR_NO_DATA;
+        rc = shClX11RequestDataForX11CallbackHelper(pCtx, VBOX_SHCL_FMT_HTML, &pv, &cb);
         if (RT_SUCCESS(rc))
         {
@@ -1679,21 +1678,26 @@
     }
 #ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
-    else if (pCtx->vboxFormats & VBOX_SHCL_FMT_URI_LIST)
-    {
-        switch (fmtX11)
-        {
-            case SHCLX11FMT_TEXT:
-                RT_FALL_THROUGH();
-            case SHCLX11FMT_UTF8:
-                RT_FALL_THROUGH();
-            case SHCLX11FMT_URI_LIST:
+    else if (fmtX11 == SHCLX11FMT_URI_LIST)
+    {
+        if (pCtx->vboxFormats & VBOX_SHCL_FMT_URI_LIST)
+        {
+            rc = shClX11RequestDataForX11CallbackHelper(pCtx, VBOX_SHCL_FMT_URI_LIST, &pv, &cb);
+            if (RT_SUCCESS(rc))
             {
-                break;
+                void *pvDst = (void *)XtMalloc(cb);
+                if (pvDst)
+                {
+                    memcpy(pvDst, pv, cb);
+
+                    *atomTypeReturn = *atomTarget;
+                    *pValReturn     = (XtPointer)pvDst;
+                    *pcLenReturn    = cb;
+                    *piFormatReturn = 8;
+                }
+                else
+                    rc = VERR_NO_MEMORY;
             }
-
-            default:
-                rc = VERR_NOT_SUPPORTED;
-                break;
-        }
+        }
+        /* else not supported yet. */
     }
 #endif
@@ -1704,6 +1708,4 @@
         *pcLenReturn    = 0;
         *piFormatReturn = 0;
-
-        rc = VERR_NOT_SUPPORTED;
     }
 
Index: trunk/src/VBox/GuestHost/SharedClipboard/testcase/tstClipboardGH-X11.cpp
===================================================================
--- trunk/src/VBox/GuestHost/SharedClipboard/testcase/tstClipboardGH-X11.cpp	(revision 87072)
+++ trunk/src/VBox/GuestHost/SharedClipboard/testcase/tstClipboardGH-X11.cpp	(revision 87082)
@@ -120,7 +120,7 @@
 
 /* Return the data in the simulated VBox clipboard. */
-DECLCALLBACK(int) ShClX11RequestDataForX11Callback(PSHCLCONTEXT pCtx, uint32_t Format, void **ppv, uint32_t *pcb)
-{
-    RT_NOREF(pCtx, Format);
+DECLCALLBACK(int) ShClX11RequestDataForX11Callback(PSHCLCONTEXT pCtx, uint32_t uFmt, void **ppv, uint32_t *pcb)
+{
+    RT_NOREF(pCtx, uFmt);
     *pcb = g_tst_cbDataVBox;
     if (g_tst_pvDataVBox != NULL)
@@ -244,8 +244,8 @@
 static uint32_t g_tst_uX11Formats = 0;
 
-DECLCALLBACK(void) ShClX11ReportFormatsCallback(PSHCLCONTEXT pCtx, SHCLFORMATS Formats)
+DECLCALLBACK(void) ShClX11ReportFormatsCallback(PSHCLCONTEXT pCtx, SHCLFORMATS fFormats)
 {
     RT_NOREF(pCtx);
-    g_tst_uX11Formats = Formats;
+    g_tst_uX11Formats = fFormats;
 }
 
Index: trunk/src/VBox/GuestHost/SharedClipboard/testcase/tstClipboardGH-X11Smoke.cpp
===================================================================
--- trunk/src/VBox/GuestHost/SharedClipboard/testcase/tstClipboardGH-X11Smoke.cpp	(revision 87072)
+++ trunk/src/VBox/GuestHost/SharedClipboard/testcase/tstClipboardGH-X11Smoke.cpp	(revision 87082)
@@ -30,13 +30,13 @@
 #include <VBox/GuestHost/clipboard-helper.h>
 
-DECLCALLBACK(int) ShClX11RequestDataForX11Callback(PSHCLCONTEXT pCtx, SHCLFORMAT Format, void **ppv, uint32_t *pcb)
+DECLCALLBACK(int) ShClX11RequestDataForX11Callback(PSHCLCONTEXT pCtx, SHCLFORMAT uFmt, void **ppv, uint32_t *pcb)
 {
-    RT_NOREF(pCtx, Format, ppv, pcb);
+    RT_NOREF(pCtx, uFmt, ppv, pcb);
     return VERR_NO_DATA;
 }
 
-DECLCALLBACK(void) ShClX11ReportFormatsCallback(PSHCLCONTEXT pCtx, SHCLFORMATS Formats)
+DECLCALLBACK(void) ShClX11ReportFormatsCallback(PSHCLCONTEXT pCtx, SHCLFORMATS fFormats)
 {
-    RT_NOREF(pCtx, Formats);
+    RT_NOREF(pCtx, fFormats);
 }
 
