VirtualBox

Changeset 5497 in vbox for trunk/src


Ignore:
Timestamp:
Oct 25, 2007 8:03:50 AM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
25684
Message:

fixed 'VBoxManage convertdd stdin <size>' when size is not divisible by 1M

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManage.cpp

    r5391 r5497  
    32283228    if (VBOX_SUCCESS(rc))
    32293229    {
    3230         RTPrintf("Creating fixed image with size %RU64Bytes (%RU64MB)...\n", cbFile, (cbFile + _1M - 1) / _1M);
     3230        RTPrintf("Creating fixed image with size %RU64 bytes (%RU64MB)...\n", cbFile, (cbFile + _1M - 1) / _1M);
    32313231        char pszComment[256];
    32323232        RTStrPrintf(pszComment, sizeof(pszComment), "Converted image from %s", argv[0]);
     
    32423242            {
    32433243                /* alloc work buffer. */
    3244                 void *pvBuf = RTMemAlloc(VDIDiskGetBufferSize(pVdi));
     3244                size_t cbBuffer = VDIDiskGetBufferSize(pVdi);
     3245                void   *pvBuf = RTMemAlloc(cbBuffer);
    32453246                if (pvBuf)
    32463247                {
    3247                     uint64_t off = 0;
    3248                     while (off < cbFile)
     3248                    uint64_t offFile = 0;
     3249                    while (offFile < cbFile)
    32493250                    {
    32503251                        size_t cbRead = 0;
    3251                         rc = RTFileRead(File, pvBuf, VDIDiskGetBufferSize(pVdi), &cbRead);
     3252                        size_t cbToRead = cbFile - offFile >= cbBuffer ? cbBuffer : cbFile - offFile;
     3253                        rc = RTFileRead(File, pvBuf, cbToRead, &cbRead);
    32523254                        if (VBOX_FAILURE(rc) || !cbRead)
    32533255                            break;
    3254                         rc = VDIDiskWrite(pVdi, off, pvBuf, cbRead);
     3256                        rc = VDIDiskWrite(pVdi, offFile, pvBuf, cbRead);
    32553257                        if (VBOX_FAILURE(rc))
    32563258                            break;
    3257                         off += cbRead;
     3259                        offFile += cbRead;
    32583260                    }
    32593261
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