From f1f3cd58b01b7b3735d65678c5f5e91ab392e9dc Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Thu, 16 May 2019 15:44:01 +0200 Subject: [PATCH] FileSystem: fix errno on lseek() beyond the bounds of a file These are all EINVAL. Also remove bogus assert on metadata.size. --- Kernel/FileSystem/FileDescriptor.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Kernel/FileSystem/FileDescriptor.cpp b/Kernel/FileSystem/FileDescriptor.cpp index a51e149c5f..e0242af169 100644 --- a/Kernel/FileSystem/FileDescriptor.cpp +++ b/Kernel/FileSystem/FileDescriptor.cpp @@ -142,17 +142,17 @@ off_t FileDescriptor::seek(off_t offset, int whence) break; case SEEK_CUR: newOffset = m_current_offset + offset; - if (newOffset < 0) - return -EINVAL; break; case SEEK_END: - ASSERT(metadata.size); // FIXME: What do I do? newOffset = metadata.size; break; default: return -EINVAL; } + if (newOffset < 0 || newOffset > metadata.size) + return -EINVAL; + m_current_offset = newOffset; return m_current_offset; }