VirtualBox

Ignore:
Timestamp:
Jul 11, 2023 8:00:15 AM (22 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
158280
Message:

Shared Clipboard: List entry reading fixes. bugref:9437

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR3LibClipboard.cpp

    r100430 r100499  
    776776            uint32_t fInfoRet;
    777777            rc = Msg.Parms.fInfo.GetUInt32(&fInfoRet);
    778             AssertRCReturn(rc, rc);
    779             AssertMsgStmt((fInfoRet & VBOX_SHCL_INFO_F_FSOBJINFO) == VBOX_SHCL_INFO_F_FSOBJINFO,
    780                           ("Host returned unknown entry info flags (%#x)\n", fInfoRet), rc = VERR_INVALID_PARAMETER);
    781778            if (RT_SUCCESS(rc))
    782779            {
    783                 uint32_t cbInfoRet = 0;
    784                 Msg.cbInfo.GetUInt32(&cbInfoRet);
    785 
    786                 AssertMsgStmt(cbInfo == cbInfoRet,
    787                               ("Host reported cbInfo %RU32, expected %RU32\n", cbInfoRet, cbInfo), rc = VERR_INVALID_PARAMETER);
    788 
    789                 rc = ShClTransferListEntryInitEx(pRootListEntry, fInfo, szName, pvInfo, cbInfo);
     780                AssertMsgStmt((fInfoRet & VBOX_SHCL_INFO_F_FSOBJINFO) == VBOX_SHCL_INFO_F_FSOBJINFO,
     781                              ("Host returned unknown root entry info flags (%#x)\n", fInfoRet), rc = VERR_INVALID_PARAMETER);
    790782                if (RT_SUCCESS(rc))
    791783                {
    792                     pvInfo = NULL;  /* Entry took ownership of pvInfo now. */
    793                     cbInfo = 0;
     784                    uint32_t cbInfoRet = 0;
     785                    rc = Msg.cbInfo.GetUInt32(&cbInfoRet);
     786                    if (RT_SUCCESS(rc))
     787                    {
     788                        AssertMsgStmt(cbInfo == cbInfoRet,
     789                                      ("Host reported cbInfo %RU32, expected %RU32\n", cbInfoRet, cbInfo), rc = VERR_INVALID_PARAMETER);
     790                        if (RT_SUCCESS(rc))
     791                            rc = ShClTransferListEntryInitEx(pRootListEntry, fInfo, szName, pvInfo, cbInfo);
     792                        if (RT_SUCCESS(rc))
     793                        {
     794                            pvInfo = NULL;  /* Entry took ownership of pvInfo now. */
     795                            cbInfo = 0;
     796                        }
     797                    }
    794798                }
    795799            }
     
    14201424                       VBOX_SHCL_GUEST_FN_LIST_ENTRY_READ, VBOX_SHCL_CPARMS_LIST_ENTRY);
    14211425
     1426    uint32_t const fInfo = VBOX_SHCL_INFO_F_FSOBJINFO; /* For now the only info we have. */
     1427
    14221428    Msg.ReqParms.uContext.SetUInt64(pCtx->idContext);
    14231429    Msg.ReqParms.uHandle.SetUInt64(hList);
    1424     Msg.ReqParms.fInfo.SetUInt32(0);
    1425 
    1426     Msg.szName.SetPtr(pListEntry->pszName, pListEntry->cbName);
    1427     Msg.cbInfo.SetUInt32(pListEntry->cbInfo);
    1428     Msg.pvInfo.SetPtr(pListEntry->pvInfo, pListEntry->cbInfo);
    1429 
    1430     int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
    1431     if (RT_SUCCESS(rc))
    1432     {
    1433         rc = Msg.cbInfo.GetUInt32(&pListEntry->cbInfo); AssertRC(rc);
    1434     }
     1430    Msg.ReqParms.fInfo.SetUInt32(fInfo);
     1431
     1432    char szName[SHCLLISTENTRY_MAX_NAME];
     1433    Msg.szName.SetPtr(szName, sizeof(szName));
     1434
     1435    void    *pvInfo = NULL;
     1436    uint32_t cbInfo = 0;
     1437
     1438    int rc = VINF_SUCCESS;
     1439
     1440    if ((fInfo & VBOX_SHCL_INFO_F_FSOBJINFO) == VBOX_SHCL_INFO_F_FSOBJINFO)
     1441    {
     1442        cbInfo = sizeof(SHCLFSOBJINFO);
     1443        pvInfo = RTMemAlloc(cbInfo);
     1444        if (!pvInfo)
     1445            rc = VERR_NO_MEMORY;
     1446    }
     1447
     1448    if (RT_SUCCESS(rc))
     1449    {
     1450        Msg.cbInfo.SetUInt32(cbInfo);
     1451        Msg.pvInfo.SetPtr(pvInfo, cbInfo);
     1452
     1453        rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
     1454        if (RT_SUCCESS(rc))
     1455        {
     1456            uint32_t cbInfoRet = 0;
     1457            rc = Msg.cbInfo.GetUInt32(&cbInfoRet);
     1458            if (RT_SUCCESS(rc))
     1459            {
     1460                AssertMsgStmt(cbInfo == cbInfoRet,
     1461                              ("Host reported cbInfo %RU32, expected %RU32\n", cbInfoRet, cbInfo), rc = VERR_INVALID_PARAMETER);
     1462                if (RT_SUCCESS(rc))
     1463                    rc = ShClTransferListEntryInitEx(pListEntry, fInfo, szName, pvInfo, cbInfo);
     1464                if (RT_SUCCESS(rc))
     1465                {
     1466                    pvInfo = NULL;  /* Entry took ownership of pvInfo now. */
     1467                    cbInfo = 0;
     1468                }
     1469            }
     1470        }
     1471        else
     1472            LogRel(("Shared Clipboard: Reading list entry failed: %Rrc\n", rc));
     1473    }
     1474
     1475    RTMemFree(pvInfo);
    14351476
    14361477    LogFlowFuncLeaveRC(rc);
     
    25142555
    25152556                    SHCLLISTENTRY entryList;
    2516                     rc = ShClTransferListRead(pTransfer, hList, &entryList);
     2557                    rc = ShClTransferListEntryInit(&entryList);
    25172558                    if (RT_SUCCESS(rc))
    25182559                    {
    2519                         PSHCLFSOBJINFO pObjInfo = (PSHCLFSOBJINFO)entryList.pvInfo;
    2520                         Assert(entryList.cbInfo == sizeof(SHCLFSOBJINFO));
    2521 
    2522                         RT_NOREF(pObjInfo);
    2523 
    2524                         LogFlowFunc(("\t%s (%RU64 bytes)\n", entryList.pszName, pObjInfo->cbObject));
    2525 
    2526                         rc = VbglR3ClipboardTransferListEntryWrite(pCmdCtx, hList, &entryList);
    2527 
    2528                         ShClTransferListEntryDestroy(&entryList);
     2560                        rc = ShClTransferListRead(pTransfer, hList, &entryList);
     2561                        if (RT_SUCCESS(rc))
     2562                        {
     2563                            PSHCLFSOBJINFO pObjInfo = (PSHCLFSOBJINFO)entryList.pvInfo;
     2564                            Assert(entryList.cbInfo == sizeof(SHCLFSOBJINFO));
     2565
     2566                            RT_NOREF(pObjInfo);
     2567
     2568                            LogFlowFunc(("\t%s (%RU64 bytes)\n", entryList.pszName, pObjInfo->cbObject));
     2569
     2570                            rc = VbglR3ClipboardTransferListEntryWrite(pCmdCtx, hList, &entryList);
     2571
     2572                            ShClTransferListEntryDestroy(&entryList);
     2573                        }
    25292574                    }
    25302575                }
Note: See TracChangeset for help on using the changeset viewer.

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