diff options
author | r-paiva <rui.paiva.10@hotmail.com> | 2021-05-06 18:35:34 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-05-08 15:22:47 +0200 |
commit | 293a5c2b49595c7a9c7a13afc5d6a1b9b40d8d91 (patch) | |
tree | a9704165244331578c54955ed32d10c3f40c2312 | |
parent | 90b6f999e599548b83f0e310146c6121a7496c30 (diff) | |
download | serenity-293a5c2b49595c7a9c7a13afc5d6a1b9b40d8d91.zip |
Kernel-VFS: Fixed kernel crash if parent custody is null
In VFS::rename, if new_path is equal to '/', then, parent custody is
set to null.
VFS::rename would then use parent custody without checking it first.
Fixed VFS::rename to check both old and new path parent custody
before actually using them.
-rw-r--r-- | Kernel/FileSystem/VirtualFileSystem.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Kernel/FileSystem/VirtualFileSystem.cpp b/Kernel/FileSystem/VirtualFileSystem.cpp index f06203c2a9..646af014fe 100644 --- a/Kernel/FileSystem/VirtualFileSystem.cpp +++ b/Kernel/FileSystem/VirtualFileSystem.cpp @@ -498,6 +498,10 @@ KResult VFS::rename(StringView old_path, StringView new_path, Custody& base) return new_custody_or_error.error(); } + if (!old_parent_custody || !new_parent_custody) { + return EPERM; + } + auto& old_parent_inode = old_parent_custody->inode(); auto& new_parent_inode = new_parent_custody->inode(); |