diff options
author | Sam Atkins <atkinssj@serenityos.org> | 2022-04-13 11:52:16 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-04-13 16:00:17 +0200 |
commit | 6967d376786ed3f02dcd968a08aa67fd0381231e (patch) | |
tree | 2b2172abd240669c0c094e520e9615022940fd34 /Userland/Libraries | |
parent | 3426592ee7b4448e71570b9240768cca86164b46 (diff) | |
download | serenity-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.cpp | 2 |
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())); |