VirtualBox

Changeset 56505 in vbox for trunk/src/VBox/Additions


Ignore:
Timestamp:
Jun 18, 2015 11:33:04 AM (10 years ago)
Author:
vboxsync
Message:

DnD: VbglR3: Also destroy scratch transfer buffer if guest file handling fails.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibDragAndDrop.cpp

    r55640 r56505  
    13031303    AssertReturn(obj.GetType() == DnDURIObject::File, VERR_INVALID_PARAMETER);
    13041304
    1305     uint32_t cbBuf = _64K; /** @todo Make this configurable? */
     1305    int rc = obj.Open(DnDURIObject::Source, RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_WRITE);
     1306    if (RT_FAILURE(rc))
     1307    {
     1308        LogFunc(("Opening file \"%s\" failed with rc=%Rrc\n", obj.GetSourcePath().c_str(), rc));
     1309        return rc;
     1310    }
     1311
     1312    uint32_t cbBuf = _64K;           /** @todo Make this configurable? */
    13061313    void *pvBuf = RTMemAlloc(cbBuf); /** @todo Make this buffer part of PVBGLR3GUESTDNDCMDCTX? */
    13071314    if (!pvBuf)
     
    13091316
    13101317    RTCString strPath = obj.GetDestPath();
    1311 
    1312     int rc = obj.Open(DnDURIObject::Source, RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_WRITE);
    1313     if (RT_FAILURE(rc))
    1314     {
    1315         LogFunc(("Opening file \"%s\" failed with rc=%Rrc\n", obj.GetSourcePath().c_str(), rc));
    1316         return rc;
    1317     }
    13181318
    13191319    LogFlowFunc(("strFile=%s (%zu), cbSize=%RU64, fMode=0x%x\n", strPath.c_str(), strPath.length(), obj.GetSize(), obj.GetMode()));
     
    13291329        MsgHdr.hdr.cParms      = 6;
    13301330
    1331         MsgHdr.uContext.SetUInt32(0); /* Context ID; unused at the moment. */
     1331        MsgHdr.uContext.SetUInt32(0);                                                    /* Context ID; unused at the moment. */
    13321332        MsgHdr.pvName.SetPtr((void *)strPath.c_str(), (uint32_t)(strPath.length() + 1));
    13331333        MsgHdr.cbName.SetUInt32((uint32_t)(strPath.length() + 1));
    1334         MsgHdr.uFlags.SetUInt32(0);   /* Flags; unused at the moment. */
    1335         MsgHdr.fMode.SetUInt32(obj.GetMode());
    1336         MsgHdr.cbTotal.SetUInt64(obj.GetSize());
     1334        MsgHdr.uFlags.SetUInt32(0);                                                      /* Flags; unused at the moment. */
     1335        MsgHdr.fMode.SetUInt32(obj.GetMode());                                           /* File mode */
     1336        MsgHdr.cbTotal.SetUInt64(obj.GetSize());                                         /* File size (in bytes). */
    13371337
    13381338        rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(MsgHdr)), &MsgHdr, sizeof(MsgHdr));
     
    14701470
    14711471        void *pvToSend = (void *)strRootDest.c_str();
    1472         uint32_t cbToSend = (uint32_t)strRootDest.length() + 1;
     1472        uint32_t cbToSend = (uint32_t)strRootDest.length() + 1; /* Include string termination. */
    14731473
    14741474        rc = vbglR3DnDGHSendDataInternal(pCtx, pvToSend, cbToSend,
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