summaryrefslogtreecommitdiff
path: root/Kernel/FileSystem
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2020-01-08 12:45:39 +0100
committerAndreas Kling <awesomekling@gmail.com>2020-01-08 12:47:41 +0100
commit28ee5b0e98e83ea091ca249e4aed10a69d2fc26c (patch)
tree7f64a2c720bb988bda6b89730b9f560877e5e61e /Kernel/FileSystem
parent50056d1d84f654043b8f4401135ec3ec08a3478c (diff)
downloadserenity-28ee5b0e98e83ea091ca249e4aed10a69d2fc26c.zip
TmpFS: Reads past the end of a file should be zero-length
Diffstat (limited to 'Kernel/FileSystem')
-rw-r--r--Kernel/FileSystem/TmpFS.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/Kernel/FileSystem/TmpFS.cpp b/Kernel/FileSystem/TmpFS.cpp
index 7df0bbb749..e468db749c 100644
--- a/Kernel/FileSystem/TmpFS.cpp
+++ b/Kernel/FileSystem/TmpFS.cpp
@@ -160,6 +160,9 @@ ssize_t TmpFSInode::read_bytes(off_t offset, ssize_t size, u8* buffer, FileDescr
if (!m_content.has_value())
return 0;
+ if (offset >= m_metadata.size)
+ return 0;
+
if (static_cast<off_t>(size) > m_metadata.size - offset)
size = m_metadata.size - offset;