summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2022-04-13 11:52:16 +0100
committerAndreas Kling <kling@serenityos.org>2022-04-13 16:00:17 +0200
commit6967d376786ed3f02dcd968a08aa67fd0381231e (patch)
tree2b2172abd240669c0c094e520e9615022940fd34 /Userland/Libraries
parent3426592ee7b4448e71570b9240768cca86164b46 (diff)
downloadserenity-6967d376786ed3f02dcd968a08aa67fd0381231e.zip
LibCore: Prevent infinite recursion in Directory::ensure_directory()
If a relative path was passed in, then repeatedly asking for its parent will never reach `/`. The top-level path in that case is `.`.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibCore/Directory.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/Userland/Libraries/LibCore/Directory.cpp b/Userland/Libraries/LibCore/Directory.cpp
index 32725992e2..a51531819d 100644
--- a/Userland/Libraries/LibCore/Directory.cpp
+++ b/Userland/Libraries/LibCore/Directory.cpp
@@ -61,7 +61,7 @@ ErrorOr<Directory> Directory::create(LexicalPath path, CreateDirectories create_
ErrorOr<void> Directory::ensure_directory(LexicalPath const& path)
{
- if (path.basename() == "/")
+ if (path.basename() == "/" || path.basename() == ".")
return {};
TRY(ensure_directory(path.parent()));