Index: /trunk/include/VBox/HostServices/VBoxClipboardSvc.h
===================================================================
--- /trunk/include/VBox/HostServices/VBoxClipboardSvc.h	(revision 82487)
+++ /trunk/include/VBox/HostServices/VBoxClipboardSvc.h	(revision 82488)
@@ -293,5 +293,5 @@
  *
  * @deprecated Replaced by VBOX_SHCL_GUEST_FN_MSG_PEEK_WAIT,
- *             VBOX_SHCL_GUEST_FN_MSG_GET, VBOX_SHCL_GUEST_FN_MSG_CANCEL.
+ *             VBOX_SHCL_GUEST_FN_MSG_GET, VBOX_SHCL_GUEST_FN_CANCEL.
  */
 #define VBOX_SHCL_GUEST_FN_GET_HOST_MSG_OLD       1
@@ -313,7 +313,8 @@
 #define VBOX_SHCL_GUEST_FN_DATA_WRITE             4
 
-/** Does the actual protocol handshake. If this message is not
- *  being sent by the guest, the host handles that particular client
- *  with the legacy protocol (v0).
+/** Does the actual protocol handshake.
+ *
+ * If this message is not being sent by the guest, the host handles that
+ * particular client with the legacy protocol (v0).
  *
  * @retval  VINF_SUCCESS on success.
@@ -339,8 +340,7 @@
 /** Query the host ones feature masks.
  *
- * That way the guest (client) can get hold of the features
- * from the host.  Again, it is prudent to set the 127 bit and observe it being
- * cleared on success, as older hosts might return success without doing
- * anything.
+ * That way the guest (client) can get hold of the features from the host.
+ * Again, it is prudent to set the 127 bit and observe it being cleared on
+ * success, as older hosts might return success without doing anything.
  *
  * @retval  VINF_SUCCESS on success.
@@ -533,4 +533,7 @@
  */
 #define VBOX_SHCL_GUEST_FN_ERROR                  27
+
+/** The last function number (used for validation/sanity).   */
+#define VBOX_SHCL_GUEST_FN_LAST                   VBOX_SHCL_GUEST_FN_ERROR
 /** @} */
 
Index: /trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc.cpp	(revision 82487)
+++ /trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc.cpp	(revision 82488)
@@ -1712,8 +1712,6 @@
              u32ClientID, u32Function, ShClGuestMsgToStr(u32Function), cParms, paParms));
 
-#ifdef DEBUG
-    uint32_t i;
-
-    for (i = 0; i < cParms; i++)
+#ifdef LOG_ENABLED
+    for (uint32_t i = 0; i < cParms; i++)
     {
         /** @todo parameters other than 32 bit */
@@ -1889,4 +1887,10 @@
             LogRel2(("Shared Clipboard: Operation canceled by guest side\n"));
 
+            /** @todo r=bird: What on earth is this?   The only user of this message
+             * (VBOX_SHCL_GUEST_FN_CANCEL) is VbglR3ClipboardMsgPeekWait(), where it was
+             * copied over from guest control.  What happens here is _nothing_ like what it
+             * expects to happen.  See GstCtrlService::clientMsgCancel for a reference.
+             */
+
             /* Reset client state and start over. */
             shclSvcClientStateReset(&pClient->State);
@@ -1918,16 +1922,20 @@
         {
 #ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
-            if (g_fTransferMode & VBOX_SHCL_TRANSFER_MODE_ENABLED)
-            {
-                rc = shClSvcTransferHandler(pClient, callHandle, u32Function, cParms, paParms, tsArrival);
+            if (u32Function <= VBOX_SHCL_GUEST_FN_LAST)
+            {
+                if (g_fTransferMode & VBOX_SHCL_TRANSFER_MODE_ENABLED)
+                    rc = shClSvcTransferHandler(pClient, callHandle, u32Function, cParms, paParms, tsArrival);
+                else
+                {
+                    LogRel2(("Shared Clipboard: File transfers are disabled for this VM\n"));
+                    rc = VERR_ACCESS_DENIED;
+                }
             }
             else
-            {
-                LogRel2(("Shared Clipboard: File transfers are disabled for this VM\n"));
-                rc = VERR_ACCESS_DENIED;
-            }
-#else
-            rc = VERR_NOT_SUPPORTED;
 #endif
+            {
+                LogRel2(("Shared Clipboard: Unknown guest function: %u (%#x)\n", u32Function, u32Function));
+                rc = VERR_NOT_IMPLEMENTED;
+            }
             break;
         }
