Skip to content

Commit 54993de

Browse files
Masamune3210elad335
authored andcommitted
unpkg: handle canonicalization failures on mounted filesystems
1 parent 0c0614a commit 54993de

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

rpcs3/Crypto/unpkg.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -952,11 +952,20 @@ bool package_reader::fill_data(std::map<std::string, install_entry*>& all_instal
952952
default:
953953
{
954954
// TODO: check for valid utf8 characters
955-
const std::string true_path = std::filesystem::weakly_canonical(path).string();
955+
std::error_code ec;
956+
std::filesystem::path normalized_path = std::filesystem::weakly_canonical(path, ec);
957+
958+
if (ec)
959+
{
960+
pkg_log.warning("Failed to canonicalize package path '%s' (%s); falling back to lexical normalization.", path, ec.message());
961+
normalized_path = std::filesystem::path(path).lexically_normal();
962+
}
963+
964+
const std::string true_path = normalized_path.string();
956965
if (true_path.empty())
957966
{
958967
num_failures++;
959-
pkg_log.error("Failed to get weakly_canonical path for '%s'", path);
968+
pkg_log.error("Failed to normalize package path for '%s'", path);
960969
break;
961970
}
962971

0 commit comments

Comments
 (0)