VirtualBox

Changeset 93113 in vbox for trunk/src


Ignore:
Timestamp:
Dec 31, 2021 11:42:50 PM (3 years ago)
Author:
vboxsync
Message:

IPRt/fatvfs.cpp: Fixed off by two cluster validation bug causing trouble accessing files using one of the last two clusters on a disk.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/fs/fatvfs.cpp

    r93084 r93113  
    12161216    {
    12171217        /* Validate the cluster, checking for end of file. */
    1218         if (   idxCluster >= pFatCache->cClusters
    1219             || idxCluster <  FAT_FIRST_DATA_CLUSTER)
     1218        if ((uint32_t)(idxCluster - FAT_FIRST_DATA_CLUSTER) >= pFatCache->cClusters)
    12201219        {
    12211220            if (idxCluster >= FAT_FIRST_FAT12_EOC)
    12221221                return VINF_SUCCESS;
     1222            Log(("Fat/ReadChain12: bogus cluster %#x vs %#x total\n", idxCluster, pFatCache->cClusters));
    12231223            return VERR_VFS_BOGUS_OFFSET;
    12241224        }
     
    12651265    {
    12661266        /* Validate the cluster, checking for end of file. */
    1267         if (   idxCluster >= pFatCache->cClusters
    1268             || idxCluster <  FAT_FIRST_DATA_CLUSTER)
     1267        if ((uint32_t)(idxCluster - FAT_FIRST_DATA_CLUSTER) >= pFatCache->cClusters)
    12691268        {
    12701269            if (idxCluster >= FAT_FIRST_FAT16_EOC)
    12711270                return VINF_SUCCESS;
     1271            Log(("Fat/ReadChain16: bogus cluster %#x vs %#x total\n", idxCluster, pFatCache->cClusters));
    12721272            return VERR_VFS_BOGUS_OFFSET;
    12731273        }
     
    12971297    {
    12981298        /* Validate the cluster, checking for end of file. */
    1299         if (   idxCluster >= pFatCache->cClusters
    1300             || idxCluster <  FAT_FIRST_DATA_CLUSTER)
     1299        if ((uint32_t)(idxCluster - FAT_FIRST_DATA_CLUSTER) >= pFatCache->cClusters)
    13011300        {
    13021301            if (idxCluster >= FAT_FIRST_FAT32_EOC)
    13031302                return VINF_SUCCESS;
     1303            Log(("Fat/ReadChain32: bogus cluster %#x vs %#x total\n", idxCluster, pFatCache->cClusters));
    13041304            return VERR_VFS_BOGUS_OFFSET;
    13051305        }
     
    25982598
    25992599/**
    2600  * Instantiates a new directory.
     2600 * Instantiates a new file.
    26012601 *
    26022602 * @returns IPRT status code.
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