diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-01-23 05:35:42 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-01-23 05:35:42 +0100 |
commit | a1b4f719bab1603294c21215419b6ecb1621b7f7 (patch) | |
tree | 73b8ec9c098d064c31efec095bb21f1bcf748b9e /Kernel/VirtualFileSystem.cpp | |
parent | 754037874c692769c703f86bfa7af641e1346139 (diff) | |
download | serenity-a1b4f719bab1603294c21215419b6ecb1621b7f7.zip |
VFS: unlink() should fail when called on a directory.
Diffstat (limited to 'Kernel/VirtualFileSystem.cpp')
-rw-r--r-- | Kernel/VirtualFileSystem.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Kernel/VirtualFileSystem.cpp b/Kernel/VirtualFileSystem.cpp index e1c62ff89f..06c8dfa73a 100644 --- a/Kernel/VirtualFileSystem.cpp +++ b/Kernel/VirtualFileSystem.cpp @@ -245,6 +245,12 @@ bool VFS::unlink(const String& path, Inode& base, int& error) return false; } + auto inode = get_inode(inode_id); + if (inode->is_directory()) { + error = -EISDIR; + return false; + } + auto parent_inode = get_inode(parent_dir); // FIXME: The reverse_lookup here can definitely be avoided. if (!parent_inode->remove_child(parent_inode->reverse_lookup(inode_id), error)) |