diff options
author | Liav A <liavalb@gmail.com> | 2023-02-18 16:48:45 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-02-19 01:01:45 +0100 |
commit | 4a14138230884083da616d7ddcc156dba5ff27de (patch) | |
tree | 848c5ef51311cbf2c86abf58fe833c07174171bd /Kernel/FileSystem/RAMFS | |
parent | 9790b81959fc31e0690380ef5c3b6e7e4a6b9802 (diff) | |
download | serenity-4a14138230884083da616d7ddcc156dba5ff27de.zip |
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.
Diffstat (limited to 'Kernel/FileSystem/RAMFS')
-rw-r--r-- | Kernel/FileSystem/RAMFS/Inode.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Kernel/FileSystem/RAMFS/Inode.cpp b/Kernel/FileSystem/RAMFS/Inode.cpp index 56f33b5b61..d2368d0b22 100644 --- a/Kernel/FileSystem/RAMFS/Inode.cpp +++ b/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_metadata.size >= 0); - if (static_cast<size_t>(m_metadata.size) < offset) + if (offset >= static_cast<size_t>(m_metadata.size)) return 0; 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); |