VirtualBox

Ignore:
Timestamp:
Nov 9, 2017 1:06:18 PM (7 years ago)
Author:
vboxsync
Message:

GuestHost/SharedClipboard/X11: fix a hang in the X11 clipboard.
bugref:9041: clipboard sharing on macOS host is brittle, Guest->Host direction

If our X11 clipboard code was asked for invalid formats by the other end it
could hang. Fix that.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/GuestHost/SharedClipboard/x11-clipboard.cpp

    r69500 r69629  
    19591959    }
    19601960    else
     1961    {
    19611962        rc = VERR_NOT_IMPLEMENTED;
     1963        pCtx->fBusy = false;
     1964    }
    19621965    if (RT_FAILURE(rc))
    19631966    {
     
    25532556}
    25542557
     2558static void testBadFormatRequestFromHost(RTTEST hTest, CLIPBACKEND *pCtx)
     2559{
     2560    clipSetSelectionValues("UTF8_STRING", XA_STRING, "hello world",
     2561                           sizeof("hello world"), 8);
     2562    clipSendTargetUpdate(pCtx);
     2563    if (clipQueryFormats() != VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT)
     2564        RTTestFailed(hTest, "Wrong targets reported: %02X\n",
     2565                     clipQueryFormats());
     2566    else
     2567    {
     2568        char *pc;
     2569        CLIPREADCBREQ *pReq = (CLIPREADCBREQ *)&pReq, *pReqRet = NULL;
     2570        ClipRequestDataFromX11(pCtx, 100, pReq);  /* Bad format. */
     2571        int rc = VINF_SUCCESS;
     2572        uint32_t cbActual = 0;
     2573        clipGetCompletedRequest(&rc, &pc, &cbActual, &pReqRet);
     2574        if (rc != VERR_NOT_IMPLEMENTED)
     2575            RTTestFailed(hTest, "Wrong return code, expected VERR_NOT_IMPLEMENTED, got %Rrc\n",
     2576                         rc);
     2577        clipSetSelectionValues("", XA_STRING, "", sizeof(""), 8);
     2578        clipSendTargetUpdate(pCtx);
     2579        if (clipQueryFormats() == VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT)
     2580            RTTestFailed(hTest, "Failed to report targets after bad host request.\n");
     2581    }
     2582}
     2583
    25552584int main()
    25562585{
     
    27562785                     (hTest, "VBox grabbed the clipboard with unknown data and we ignored it\n"));
    27572786    testStringFromVBoxFailed(hTest, pCtx, "UTF8_STRING");
     2787
     2788    /*** VBox requests a bad format ***/
     2789    RTTestSub(hTest, "recovery from a bad format request");
     2790    testBadFormatRequestFromHost(hTest, pCtx);
     2791
    27582792    rc = ClipStopX11(pCtx);
    27592793    AssertRCReturn(rc, 1);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette