Bläddra i källkod

Kernel/FileSystem: Fix check of read offset for the RAMFSInode code

The check of ensuring we are not trying to read beyond the end of the
inode data buffer is already there, it's just that we need to disallow
further reading if the read offset equals to the inode data size.
Liav A 2 år sedan
förälder
incheckning
4a14138230
1 ändrade filer med 1 tillägg och 1 borttagningar
  1. 1 1
      Kernel/FileSystem/RAMFS/Inode.cpp

+ 1 - 1
Kernel/FileSystem/RAMFS/Inode.cpp

@@ -127,7 +127,7 @@ ErrorOr<size_t> RAMFSInode::read_bytes_from_content_space(size_t offset, size_t
 {
 {
     VERIFY(m_inode_lock.is_locked());
     VERIFY(m_inode_lock.is_locked());
     VERIFY(m_metadata.size >= 0);
     VERIFY(m_metadata.size >= 0);
-    if (static_cast<size_t>(m_metadata.size) < offset)
+    if (offset >= static_cast<size_t>(m_metadata.size))
         return 0;
         return 0;
     auto mapping_region = TRY(MM.allocate_kernel_region(DataBlock::block_size, "RAMFSInode Mapping Region"sv, Memory::Region::Access::Read, AllocationStrategy::Reserve));
     auto mapping_region = TRY(MM.allocate_kernel_region(DataBlock::block_size, "RAMFSInode Mapping Region"sv, Memory::Region::Access::Read, AllocationStrategy::Reserve));
     return const_cast<RAMFSInode&>(*this).do_io_on_content_space(*mapping_region, offset, io_size, buffer, false);
     return const_cast<RAMFSInode&>(*this).do_io_on_content_space(*mapping_region, offset, io_size, buffer, false);