mirror of
https://github.com/RGBCube/serenity
synced 2025-06-30 10:12:07 +00:00
Kernel/FileSystem: Add check of read offset for the FATInode code
Apparently we lacked this important check from the beginning of this piece of code. This check is crucial to ensure we only give back data being related to the FATInode data buffer and nothing beyond it.
This commit is contained in:
parent
6cc5e09c71
commit
9790b81959
1 changed files with 3 additions and 0 deletions
|
@ -201,6 +201,9 @@ u32 FATInode::first_cluster() const
|
|||
ErrorOr<size_t> FATInode::read_bytes_locked(off_t offset, size_t size, UserOrKernelBuffer& buffer, OpenFileDescription*) const
|
||||
{
|
||||
dbgln_if(FAT_DEBUG, "FATFS: Reading inode {}: size: {} offset: {}", identifier().index(), size, offset);
|
||||
VERIFY(offset >= 0);
|
||||
if (offset >= m_metadata.size)
|
||||
return 0;
|
||||
|
||||
// FIXME: Read only the needed blocks instead of the whole file
|
||||
auto blocks = TRY(const_cast<FATInode&>(*this).read_block_list());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue