mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-20 01:01:54 +00:00
Kernel: Return error when attempting to read from a directory.
We now return EISDIR whenever a program attempts to call sys$read on a directory. Previously, attempting to read a directory could either return junk data or, in the case of /proc/, cause a kernel panic.
This commit is contained in:
parent
1be4c6e9cf
commit
489e451cce
Notes:
sideshowbarker
2024-07-19 11:33:26 +09:00
Author: https://github.com/DrewStratford
Commit: 489e451cce
Pull-request: https://github.com/SerenityOS/serenity/pull/686
1 changed files with 2 additions and 0 deletions
|
@ -1128,6 +1128,8 @@ ssize_t Process::sys$read(int fd, u8* buffer, ssize_t size)
|
|||
auto* description = file_description(fd);
|
||||
if (!description)
|
||||
return -EBADF;
|
||||
if (description->is_directory())
|
||||
return -EISDIR;
|
||||
if (description->is_blocking()) {
|
||||
if (!description->can_read()) {
|
||||
if (current->block<Thread::ReadBlocker>(*description) == Thread::BlockResult::InterruptedBySignal)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue