Kernel: VFS now has max link depth of 100

This commit is contained in:
Bananymous 2023-06-02 12:50:40 +03:00
parent 4d4d0e26a9
commit 633cb4f282
1 changed files with 7 additions and 1 deletions

View File

@ -98,9 +98,11 @@ namespace Kernel
{ {
auto temp = TRY(path.split('/')); auto temp = TRY(path.split('/'));
for (size_t i = 0; i < temp.size(); i++) 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()) while (!path_parts.empty())
{ {
const auto& path_part = path_parts.back(); const auto& path_part = path_parts.back();
@ -165,6 +167,10 @@ namespace Kernel
for (size_t i = 0; i < new_parts.size(); i++) for (size_t i = 0; i < new_parts.size(); i++)
TRY(path_parts.emplace_back(new_parts[new_parts.size() - i - 1])); TRY(path_parts.emplace_back(new_parts[new_parts.size() - i - 1]));
} }
link_depth++;
if (link_depth > 100)
return BAN::Error::from_errno(ELOOP);
} }
} }