1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-15 01:24:57 +00:00

TmpFS: Reads past the end of a file should be zero-length

This commit is contained in:
Andreas Kling 2020-01-08 12:45:39 +01:00
parent 50056d1d84
commit 28ee5b0e98
2 changed files with 23 additions and 0 deletions

View file

@ -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;