summaryrefslogtreecommitdiff
path: root/Kernel/FileSystem
diff options
context:
space:
mode:
authorSergey Bugaev <bugaevc@gmail.com>2019-06-13 16:33:01 +0300
committerAndreas Kling <awesomekling@gmail.com>2019-06-14 06:24:02 +0200
commit27203369b4ed89c3780d9cc1903c349e501ef886 (patch)
tree0a2b76736ef5f414a81300efacb7ee108e19fdf6 /Kernel/FileSystem
parent1a697f70db770f630de74dc717d189067a89b0d7 (diff)
downloadserenity-27203369b4ed89c3780d9cc1903c349e501ef886.zip
Kernel: Fix not returning errors for the last path item.
Previously the check for an empty part would happen before the check for access and for the parent being a directory, and so an error in those would not be detected.
Diffstat (limited to 'Kernel/FileSystem')
-rw-r--r--Kernel/FileSystem/VirtualFileSystem.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/Kernel/FileSystem/VirtualFileSystem.cpp b/Kernel/FileSystem/VirtualFileSystem.cpp
index b4987089fd..296821094e 100644
--- a/Kernel/FileSystem/VirtualFileSystem.cpp
+++ b/Kernel/FileSystem/VirtualFileSystem.cpp
@@ -650,9 +650,6 @@ KResultOr<Retained<Custody>> VFS::resolve_path(StringView path, Custody& base, R
for (int i = 0; i < parts.size(); ++i) {
bool inode_was_root_at_head_of_loop = crumb_id.is_root_inode();
- auto& part = parts[i];
- if (part.is_empty())
- break;
auto crumb_inode = get_inode(crumb_id);
if (!crumb_inode)
return KResult(-EIO);
@@ -661,6 +658,11 @@ KResultOr<Retained<Custody>> VFS::resolve_path(StringView path, Custody& base, R
return KResult(-ENOTDIR);
if (!metadata.may_execute(current->process()))
return KResult(-EACCES);
+
+ auto& part = parts[i];
+ if (part.is_empty())
+ break;
+
auto current_parent = custody_chain.last();
crumb_id = crumb_inode->lookup(part);
if (!crumb_id.is_valid())