Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions engine/repositories/file_fs_repository.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,10 @@ std::filesystem::path SanitizePath(const std::filesystem::path& user_input,
std::filesystem::path resolved_path = std::filesystem::weakly_canonical(
std::filesystem::path(basedir) / std::filesystem::path(user_input));
/* Ensure the resolved path is within our basedir */
for (auto p = resolved_path; !p.empty(); p = p.parent_path()) {
if (std::filesystem::equivalent(p, abs_base)) {
return resolved_path;
}
if (p == p.parent_path()) { // reached the root directory
break;
}
if (resolved_path.string().find(abs_base.string()) != std::string::npos) {
return resolved_path;
}

return {};
}

Expand Down
Loading