mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-11-26 07:11:23 -05:00
List and Load Resource Textures Whose Paths Pass MAX_PATH on Windows (#17730)
* Test Resource Textures Whose Paths Pass MAX_PATH * List and Load Resource Textures Whose Paths Pass MAX_PATH on Windows
This commit is contained in:
1 parent
1e1543f006
commit
0d7bea5763
3 files changed
+75
-6
No files matched your search
@@ -1701,8 +1701,12 @@ std::vector<std::string> collect_resource_texture_files(const std::string& dir,
|
||||
|
||||
for (fs::directory_iterator it(resolved_dir, ec), end; it != end && !ec; it.increment(ec)) {
|
||||
const fs::path& path = it->path();
|
||||
// Plugin extraction writes through extended_path(), so a pack file can sit past Windows'
|
||||
// MAX_PATH; the plain path cannot reach it there.
|
||||
const fs::path io_path = extended_path(path);
|
||||
boost::system::error_code file_ec;
|
||||
|
||||
if (!fs::is_regular_file(path, ec) || ec)
|
||||
if (!fs::is_regular_file(io_path, file_ec) || file_ec)
|
||||
continue;
|
||||
|
||||
std::string ext = path.extension().string();
|
||||
@@ -1710,8 +1714,12 @@ std::vector<std::string> collect_resource_texture_files(const std::string& dir,
|
||||
if (ext != ".png" && ext != ".jpg" && ext != ".jpeg" && ext != ".bmp")
|
||||
continue;
|
||||
|
||||
// Re-check per file: a symlink inside the pack must not resolve outside it.
|
||||
if (!is_inside_allowed_root(path, resolved_root))
|
||||
// Re-check per file: a symlink inside the pack must not resolve outside it. Any other entry is a
|
||||
// direct child of resolved_dir, checked above. is_inside_allowed_root() resolves the plain path,
|
||||
// so a symlink that path cannot reach is refused rather than trusted.
|
||||
const fs::file_status status = fs::symlink_status(io_path, file_ec);
|
||||
if (file_ec || (fs::is_symlink(status) && (!fs::exists(path, file_ec) || file_ec ||
|
||||
!is_inside_allowed_root(path, resolved_root))))
|
||||
continue;
|
||||
|
||||
files.push_back(path.string());
|
||||
|
||||
Reference in new issue
Block a user