[haiku-commits] haiku: hrev52939 - src/add-ons/kernel/file_systems/exfat

  • From: Jérôme Duval <jerome.duval@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 26 Feb 2019 17:09:42 -0500 (EST)

hrev52939 adds 1 changeset to branch 'master'
old head: 1b3684f86ad0a877522ab2e00e1ca2fb704da718
new head: 1d3959edfb0741a8a8ac768638133add307f8a19
overview: 
https://git.haiku-os.org/haiku/log/?qt=range&q=1d3959edfb07+%5E1b3684f86ad0

----------------------------------------------------------------------------

1d3959edfb07: exfat: checks cluster values.
  
  also use the size of the node for Size(), instead of the valid size.

                                   [ Jérôme Duval <jerome.duval@xxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev52939
Commit:      1d3959edfb0741a8a8ac768638133add307f8a19
URL:         https://git.haiku-os.org/haiku/commit/?id=1d3959edfb07
Author:      Jérôme Duval <jerome.duval@xxxxxxxxx>
Date:        Tue Feb 26 22:07:38 2019 UTC

----------------------------------------------------------------------------

4 files changed, 10 insertions(+), 5 deletions(-)
src/add-ons/kernel/file_systems/exfat/DataStream.cpp        | 3 ++-
src/add-ons/kernel/file_systems/exfat/DirectoryIterator.cpp | 6 ++++--
src/add-ons/kernel/file_systems/exfat/Volume.cpp            | 4 +++-
src/add-ons/kernel/file_systems/exfat/exfat.h               | 2 +-

----------------------------------------------------------------------------

diff --git a/src/add-ons/kernel/file_systems/exfat/DataStream.cpp 
b/src/add-ons/kernel/file_systems/exfat/DataStream.cpp
index 5a9647e7c8..f1123c1954 100644
--- a/src/add-ons/kernel/file_systems/exfat/DataStream.cpp
+++ b/src/add-ons/kernel/file_systems/exfat/DataStream.cpp
@@ -52,7 +52,8 @@ DataStream::FindBlock(off_t pos, off_t& physical, off_t 
*_length)
        for (uint32 i = 0; i < clusterIndex; i++)
                cluster = fInode->NextCluster(cluster);
        fsblock_t block;
-       fVolume->ClusterToBlock(cluster, block);
+       if (fVolume->ClusterToBlock(cluster, block) != B_OK)
+               return B_BAD_DATA;
        physical = block * kBlockSize + offset;
        for (uint32 i = 0; i < 64; i++) {
                cluster_t extentEnd = fInode->NextCluster(cluster);
diff --git a/src/add-ons/kernel/file_systems/exfat/DirectoryIterator.cpp 
b/src/add-ons/kernel/file_systems/exfat/DirectoryIterator.cpp
index 278af03b1e..24e81d1c53 100644
--- a/src/add-ons/kernel/file_systems/exfat/DirectoryIterator.cpp
+++ b/src/add-ons/kernel/file_systems/exfat/DirectoryIterator.cpp
@@ -275,7 +275,8 @@ DirectoryIterator::_NextEntry()
 {
        if (fCurrent == NULL) {
                fsblock_t block;
-               fInode->GetVolume()->ClusterToBlock(fCluster, block);
+               if (fInode->GetVolume()->ClusterToBlock(fCluster, block) != 
B_OK)
+                       return B_BAD_DATA;
                block += (fOffset / fInode->GetVolume()->EntriesPerBlock())
                        % (1 << 
fInode->GetVolume()->SuperBlock().BlocksPerClusterShift());
                TRACE("DirectoryIterator::_NextEntry() init to block %" 
B_PRIu64 "\n",
@@ -289,7 +290,8 @@ DirectoryIterator::_NextEntry()
                        if (fCluster == EXFAT_CLUSTER_END)
                                return B_ENTRY_NOT_FOUND;
 
-                       fInode->GetVolume()->ClusterToBlock(fCluster, block);
+                       if (fInode->GetVolume()->ClusterToBlock(fCluster, 
block) != B_OK)
+                               return B_BAD_DATA;
                } else
                        block = fBlock.BlockNumber() + 1;
 
diff --git a/src/add-ons/kernel/file_systems/exfat/Volume.cpp 
b/src/add-ons/kernel/file_systems/exfat/Volume.cpp
index aa9dbbe5e3..b6f7b1a7f3 100644
--- a/src/add-ons/kernel/file_systems/exfat/Volume.cpp
+++ b/src/add-ons/kernel/file_systems/exfat/Volume.cpp
@@ -416,8 +416,10 @@ Volume::LoadSuperBlock()
 status_t
 Volume::ClusterToBlock(cluster_t cluster, fsblock_t &block)
 {
-       if (cluster < EXFAT_FIRST_DATA_CLUSTER)
+       if ((cluster - EXFAT_FIRST_DATA_CLUSTER) >= SuperBlock().ClusterCount()
+               || cluster < EXFAT_FIRST_DATA_CLUSTER) {
                return B_BAD_VALUE;
+       }
        block = ((fsblock_t)(cluster - EXFAT_FIRST_DATA_CLUSTER)
                << SuperBlock().BlocksPerClusterShift())
                + SuperBlock().FirstDataBlock();
diff --git a/src/add-ons/kernel/file_systems/exfat/exfat.h 
b/src/add-ons/kernel/file_systems/exfat/exfat.h
index b33888eb46..09a7d326ea 100644
--- a/src/add-ons/kernel/file_systems/exfat/exfat.h
+++ b/src/add-ons/kernel/file_systems/exfat/exfat.h
@@ -170,7 +170,7 @@ struct exfat_entry {
                        void SetFlag(uint8 newFlag)
                                { flag = newFlag; }
                        uint64 Size() const
-                               { return B_LENDIAN_TO_HOST_INT64(size1); }
+                               { return B_LENDIAN_TO_HOST_INT64(size2); }
                } _PACKED file_info;
                struct {
                        uint8 flags;


Other related posts:

  • » [haiku-commits] haiku: hrev52939 - src/add-ons/kernel/file_systems/exfat - Jérôme Duval