VirtualBox

Changeset 57469 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Aug 20, 2015 9:07:56 AM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
102237
Message:

DnD: Fixed host->guest crashes on OS X hosts.

Location:
trunk/src/VBox/Main
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/GuestDnDPrivate.h

    r57221 r57469  
    107107    }
    108108
     109    int Init(size_t cbBuf = _64K)
     110    {
     111        Reset();
     112
     113        pvScratchBuf = RTMemAlloc(cbBuf);
     114        if (!pvScratchBuf)
     115            return VERR_NO_MEMORY;
     116
     117        cbScratchBuf = cbBuf;
     118        return VINF_SUCCESS;
     119    }
     120
     121    void *const GetBufferMutable(void) { return pvScratchBuf; }
     122
     123    size_t GetBufferSize(void) { return cbScratchBuf; }
     124
    109125    void Reset(void)
    110126    {
     
    129145    /** Current object to receive. */
    130146    DnDURIObject                    objURI;
     147
     148protected:
     149
    131150    /** Pointer to an optional scratch buffer to use for
    132151     *  doing the actual chunk transfers. */
  • trunk/src/VBox/Main/src-client/GuestDnDTargetImpl.cpp

    r57358 r57469  
    912912    uint32_t cbRead = 0;
    913913
    914     int rc = pObject->Read(pCtx->mURI.pvScratchBuf, pCtx->mURI.cbScratchBuf, &cbRead);
     914    int rc = pObject->Read(pCtx->mURI.GetBufferMutable(), pCtx->mURI.GetBufferSize(), &cbRead);
    915915    if (RT_SUCCESS(rc))
    916916    {
     
    919919        if (mDataBase.mProtocolVersion <= 1)
    920920        {
    921             pMsg->setNextPointer(pCtx->mURI.pvScratchBuf, cbRead); /* pvData */
    922             pMsg->setNextUInt32(cbRead);                            /* cbData */
    923             pMsg->setNextUInt32(pObject->GetMode());                   /* fMode */
     921            pMsg->setNextPointer(pCtx->mURI.GetBufferMutable(), cbRead); /* pvData */
     922            pMsg->setNextUInt32(cbRead);                                 /* cbData */
     923            pMsg->setNextUInt32(pObject->GetMode());                     /* fMode */
    924924        }
    925925        else
    926926        {
    927             pMsg->setNextPointer(pCtx->mURI.pvScratchBuf, cbRead); /* pvData */
    928             pMsg->setNextUInt32(cbRead);                           /* cbData */
     927            pMsg->setNextPointer(pCtx->mURI.GetBufferMutable(), cbRead); /* pvData */
     928            pMsg->setNextUInt32(cbRead);                                 /* cbData */
    929929        }
    930930
     
    11171117    }
    11181118
    1119     void *pvBuf = RTMemAlloc(mData.mcbBlockSize);
    1120     if (!pvBuf)
    1121         return VERR_NO_MEMORY;
    1122 
    1123     int rc;
    1124 
    11251119#define REGISTER_CALLBACK(x)                                        \
    11261120    rc = pCtx->mpResp->setCallback(x, i_sendURIDataCallback, pCtx); \
     
    11331127        AssertRC(rc2);                                \
    11341128    }
     1129
     1130    int rc = pCtx->mURI.Init(mData.mcbBlockSize);
     1131    if (RT_FAILURE(rc))
     1132        return rc;
    11351133
    11361134    rc = pCtx->mCallback.Reset();
     
    11531151    {
    11541152        /*
    1155          * Set our scratch buffer.
    1156          */
    1157         pCtx->mURI.pvScratchBuf = pvBuf;
    1158         pCtx->mURI.cbScratchBuf = mData.mcbBlockSize;
    1159 
    1160         /*
    11611153         * Extract URI list from byte data.
    11621154         */
     
    11721164        URI_DATA_IS_VALID_BREAK(!lstURIOrg.isEmpty());
    11731165
    1174         rc = lstURI.AppendURIPathsFromList(lstURIOrg, 0 /* fFlags */);
     1166        uint32_t fFlags = DNDURILIST_FLAGS_KEEP_OPEN;
     1167
     1168        rc = lstURI.AppendURIPathsFromList(lstURIOrg, fFlags);
    11751169        if (RT_SUCCESS(rc))
    11761170            LogFlowFunc(("URI root objects: %zu, total bytes (raw data to transfer): %zu\n",
     
    12441238    }
    12451239
    1246     /* Destroy temporary scratch buffer. */
    1247     if (pvBuf)
    1248         RTMemFree(pvBuf);
    1249 
    12501240#undef URI_DATA_IS_VALID_BREAK
    12511241
     
    12591249
    12601250    DnDURIList &lstURI = pCtx->mURI.lstURI;
    1261 
    1262     int rc;
    12631251
    12641252    uint64_t cbTotal = pCtx->mData.cbToProcess;
     
    12921280                 fMode, pCurObj->GetSize(),
    12931281                 RTFS_IS_DIRECTORY(fMode), RTFS_IS_FILE(fMode)));
    1294 
     1282    int rc;
    12951283    if (RTFS_IS_DIRECTORY(fMode))
    12961284    {
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