diff options
author | Andreas Kling <kling@serenityos.org> | 2021-04-04 17:21:07 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-04-04 17:21:07 +0200 |
commit | 5001b71c423f378299b33643ad3be042a8b86dc3 (patch) | |
tree | 09e48ac18014de0a2c5b775656fa18af9e3c947b /Kernel/FileSystem/Ext2FileSystem.cpp | |
parent | 23cc88f83ba09a87f49096fe9d5866ef65148a4d (diff) | |
download | serenity-5001b71c423f378299b33643ad3be042a8b86dc3.zip |
Kernel: Reading past the end of an Ext2FSInode should return 0
Fixes #5763.
Diffstat (limited to 'Kernel/FileSystem/Ext2FileSystem.cpp')
-rw-r--r-- | Kernel/FileSystem/Ext2FileSystem.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Kernel/FileSystem/Ext2FileSystem.cpp b/Kernel/FileSystem/Ext2FileSystem.cpp index 7103368509..dffbdd7363 100644 --- a/Kernel/FileSystem/Ext2FileSystem.cpp +++ b/Kernel/FileSystem/Ext2FileSystem.cpp @@ -857,6 +857,9 @@ ssize_t Ext2FSInode::read_bytes(off_t offset, ssize_t count, UserOrKernelBuffer& if (m_raw_inode.i_size == 0) return 0; + if (static_cast<u64>(offset) >= size()) + return 0; + // Symbolic links shorter than 60 characters are store inline inside the i_block array. // This avoids wasting an entire block on short links. (Most links are short.) if (is_symlink() && size() < max_inline_symlink_length) { |