VirtualBox

Changeset 34581 in vbox


Ignore:
Timestamp:
Dec 1, 2010 4:43:39 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
68376
Message:

Storage/VMDK: reading of fixed image descriptor files needs to handle the sequential case

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Storage/VMDK.cpp

    r34014 r34581  
    33303330            goto out;
    33313331
     3332        /* If the descriptor file is shorter than 50 bytes it can't be valid. */
     3333        if (cbFileSize < 50)
     3334        {
     3335            rc = vmdkError(pImage, VERR_VD_VMDK_INVALID_HEADER, RT_SRC_POS, N_("VMDK: descriptor in '%s' is too short"), pImage->pszFilename);
     3336            goto out;
     3337        }
     3338
    33323339        uint64_t cbSize = cbFileSize;
    33333340        if (cbSize % VMDK_SECTOR2BYTE(10))
     
    33443351        }
    33453352
     3353        /* Don't reread the place where the magic would live in a sparse
     3354         * image if it's a descriptor based one. */
     3355        memcpy(pImage->pDescData, &u32Magic, sizeof(u32Magic));
    33463356        size_t cbRead;
    3347         rc = vmdkFileReadSync(pImage, pImage->pFile, 0, pImage->pDescData,
    3348                               RT_MIN(pImage->cbDescAlloc, cbFileSize),
     3357        rc = vmdkFileReadSync(pImage, pImage->pFile, sizeof(u32Magic),
     3358                              pImage->pDescData + sizeof(u32Magic),
     3359                              RT_MIN(pImage->cbDescAlloc - sizeof(u32Magic),
     3360                                     cbFileSize - sizeof(u32Magic)),
    33493361                              &cbRead);
    33503362        if (RT_FAILURE(rc))
     
    33533365            goto out;
    33543366        }
     3367        cbRead += sizeof(u32Magic);
    33553368        if (cbRead == pImage->cbDescAlloc)
    33563369        {
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