From 633cb4f282248c12bd6f07682b3de37cfea117d2 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Fri, 2 Jun 2023 12:50:40 +0300 Subject: [PATCH] Kernel: VFS now has max link depth of 100 --- kernel/kernel/FS/VirtualFileSystem.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/kernel/kernel/FS/VirtualFileSystem.cpp b/kernel/kernel/FS/VirtualFileSystem.cpp index 86bcbb2f..df210eca 100644 --- a/kernel/kernel/FS/VirtualFileSystem.cpp +++ b/kernel/kernel/FS/VirtualFileSystem.cpp @@ -98,9 +98,11 @@ namespace Kernel { auto temp = TRY(path.split('/')); for (size_t i = 0; i < temp.size(); i++) - TRY(path_parts.push_back(temp[temp.size() - i - 1])); + TRY(path_parts.emplace_back(temp[temp.size() - i - 1])); } + size_t link_depth = 0; + while (!path_parts.empty()) { const auto& path_part = path_parts.back(); @@ -165,6 +167,10 @@ namespace Kernel for (size_t i = 0; i < new_parts.size(); i++) TRY(path_parts.emplace_back(new_parts[new_parts.size() - i - 1])); } + + link_depth++; + if (link_depth > 100) + return BAN::Error::from_errno(ELOOP); } }