Kernel: Reading from fd verifies that file is opened for reading

This commit is contained in:
Bananymous 2023-03-21 21:20:43 +02:00
parent a8e3ee6f19
commit b222581d18
1 changed files with 2 additions and 0 deletions

View File

@ -108,6 +108,8 @@ namespace Kernel
BAN::ErrorOr<size_t> Process::OpenFileDescription::read(void* buffer, size_t count)
{
if (!(flags & O_RDONLY))
return BAN::Error::from_errno(EBADF);
size_t n_read = TRY(inode->read(offset, buffer, count));
offset += n_read;
return n_read;