VirtualBox

Changeset 72577 in vbox for trunk/src/VBox/Storage


Ignore:
Timestamp:
Jun 15, 2018 9:31:58 PM (6 years ago)
Author:
vboxsync
Message:

Storage/VHD: Stay within possible limits of the VDH spec for the block allocation table and reject images violating the spec, missing status code check [build fix]

File:
1 edited

Legend:

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

    r72574 r72577  
    4747#define VHD_MAX_SIZE    (2 * _1T)
    4848/** Maximum number of 512 byte sectors for a VHD image. */
    49 #define VHD_MAX_SECTORS ((uint32_t)(VHD_MAX_SIZE / VHD_SECTOR_SIZE))
     49#define VHD_MAX_SECTORS (VHD_MAX_SIZE / VHD_SECTOR_SIZE)
    5050
    5151/* This is common to all VHD disk types and is located at the end of the image */
     
    756756    AssertMsg(!(pImage->cbDataBlock % VHD_SECTOR_SIZE), ("%s: Data block size is not a multiple of %!\n", __FUNCTION__, VHD_SECTOR_SIZE));
    757757
    758     /* Bail out if the number of BAT entries exceeds the number of sectors for a maximum image. */
    759     if (pImage->cBlockAllocationTableEntries > VHD_MAX_SECTORS)
     758    /*
     759     * Bail out if the number of BAT entries exceeds the number of sectors for a maximum image.
     760     * Lower the number of sectors in the BAT as a few sectors are already occupied by the footers
     761     * and headers.
     762     */
     763    if (pImage->cBlockAllocationTableEntries > (VHD_MAX_SECTORS - 2))
    760764        return VERR_VD_VHD_INVALID_HEADER;
    761765
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