VirtualBox

Changeset 20695 in vbox


Ignore:
Timestamp:
Jun 18, 2009 5:08:08 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
48800
Message:

VHD: Fix access beyond the block bitmap which can lead to arbitrary crashes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Storage/VHDHDDCore.cpp

    r20473 r20695  
    956956                uint32_t iBATEntryIndexCurr = cBATEntryIndex + 1;
    957957
     958                cSectors = 1;
     959
    958960                /*
    959961                 * The first sector being read is marked dirty, read as much as we
     
    961963                 * must be read from child.
    962964                 */
    963                 do
     965                while (cSectors < (cbRead / VHD_SECTOR_SIZE))
    964966                {
    965                     cSectors++;
    966967
    967968                    iBitmap    = iBATEntryIndexCurr / 8; /* Byte in the block bitmap. */
    968969                    iBitInByte = (8 - 1) - (iBATEntryIndexCurr % 8);
    969970                    puBitmap  = pImage->pu8Bitmap + iBitmap;
     971                    AssertMsg(puBitmap < (pImage->pu8Bitmap + pImage->cbDataBlockBitmap),
     972                              ("VHD: Current bitmap position exceeds maximum size of the bitmap\n"));
    970973                    if (!ASMBitTest(puBitmap, iBitInByte))
    971974                        break;
    972975
    973976                    iBATEntryIndexCurr++;
    974                 } while (cSectors < (cbRead / VHD_SECTOR_SIZE));
     977                    cSectors++;
     978                }
    975979
    976980                cbRead = cSectors * VHD_SECTOR_SIZE;
     
    991995                 * should be read from the parent.
    992996                 */
    993                 do
     997
     998                cSectors = 1;
     999
     1000                while (cSectors < (cbRead / VHD_SECTOR_SIZE))
    9941001                {
    995                     cSectors++;
    996 
    9971002                    iBitmap    = iBATEntryIndexCurr / 8; /* Byte in the block bitmap. */
    9981003                    iBitInByte = (8 - 1) - (iBATEntryIndexCurr % 8);
    9991004                    puBitmap  = pImage->pu8Bitmap + iBitmap;
     1005                    AssertMsg(puBitmap < (pImage->pu8Bitmap + pImage->cbDataBlockBitmap),
     1006                              ("VHD: Current bitmap position exceeds maximum size of the bitmap\n"));
    10001007                    if (ASMBitTest(puBitmap, iBitInByte))
    10011008                        break;
    10021009
    10031010                    iBATEntryIndexCurr++;
    1004                 } while (cSectors < (cbRead / VHD_SECTOR_SIZE));
     1011                    cSectors++;
     1012                }
    10051013
    10061014                cbRead = cSectors * VHD_SECTOR_SIZE;
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