From c8074d2c6e5eaa228e6d37be9a682b4c5a393162 Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Wed, 24 Aug 2022 15:46:08 +0200 Subject: [PATCH] lsp: Limit resolvesToRegularFile()'s recursion depth to 10. --- libsolidity/lsp/LanguageServer.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libsolidity/lsp/LanguageServer.cpp b/libsolidity/lsp/LanguageServer.cpp index 6ea60e0cf..65eeaf3d5 100644 --- a/libsolidity/lsp/LanguageServer.cpp +++ b/libsolidity/lsp/LanguageServer.cpp @@ -58,14 +58,15 @@ namespace fs = boost::filesystem; namespace { -bool resolvesToRegularFile(boost::filesystem::path _path) +bool resolvesToRegularFile(boost::filesystem::path _path, int maxRecursionDepth = 10) { fs::file_status fileStatus = fs::status(_path); - while (fileStatus.type() == fs::file_type::symlink_file) + while (fileStatus.type() == fs::file_type::symlink_file && maxRecursionDepth > 0) { _path = boost::filesystem::read_symlink(_path); fileStatus = fs::status(_path); + maxRecursionDepth--; } return fileStatus.type() == fs::file_type::regular_file;