diff options
author | Max Wipfli <mail@maxwipfli.ch> | 2021-07-11 14:46:15 +0200 |
---|---|---|
committer | Idan Horowitz <idan.horowitz@gmail.com> | 2022-02-13 21:58:26 +0200 |
commit | 8c7010f282e5b6757e167326e73f6b05ff125575 (patch) | |
tree | 0079de6a808652352e5ed71aa2f1f208b6f02c34 /Kernel | |
parent | 3ebb3d9d52bbfae294572542490634e49b4374a4 (diff) | |
download | serenity-8c7010f282e5b6757e167326e73f6b05ff125575.zip |
Kernel/VFS: Clear out_parent if path is veiled
Previously, VirtualFileSystem::resolve_path() could return a non-null
RefPtr<Custody>* out_parent even if the function errored because the
path has been veiled.
If code relies on recieving the parent custody even if the path is
veiled, it should just call resolve_path_without_veil and do the veil
validation manually. This is because it could be that the parent is
unveiled but the child isn't or the other way round.
Diffstat (limited to 'Kernel')
-rw-r--r-- | Kernel/FileSystem/VirtualFileSystem.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Kernel/FileSystem/VirtualFileSystem.cpp b/Kernel/FileSystem/VirtualFileSystem.cpp index 8efdacc338..c2a3f4d565 100644 --- a/Kernel/FileSystem/VirtualFileSystem.cpp +++ b/Kernel/FileSystem/VirtualFileSystem.cpp @@ -828,7 +828,11 @@ ErrorOr<void> VirtualFileSystem::validate_path_against_process_veil(StringView p ErrorOr<NonnullRefPtr<Custody>> VirtualFileSystem::resolve_path(StringView path, Custody& base, RefPtr<Custody>* out_parent, int options, int symlink_recursion_level) { auto custody = TRY(resolve_path_without_veil(path, base, out_parent, options, symlink_recursion_level)); - TRY(validate_path_against_process_veil(*custody, options)); + if (auto result = validate_path_against_process_veil(*custody, options); result.is_error()) { + if (out_parent) + out_parent->clear(); + return result.release_error(); + } return custody; } |