mirror of
https://github.com/stenzek/duckstation.git
synced 2025-06-07 03:55:33 +00:00
PCDrv: Allow opening by absolute path
This commit is contained in:
parent
ae9023ddf3
commit
ece18d10c5
@ -79,17 +79,18 @@ static bool CloseFileHandle(u32 handle)
|
||||
|
||||
static std::string ResolveHostPath(const std::string& path)
|
||||
{
|
||||
// Double-check that it falls within the directory of the elf.
|
||||
// Double-check that it falls within the directory of the root.
|
||||
// Not a real sandbox, but emulators shouldn't be treated as such. Don't run untrusted code!
|
||||
const std::string& root = g_settings.pcdrv_root;
|
||||
std::string canonicalized_path = Path::Canonicalize(Path::Combine(root, path));
|
||||
std::string canonicalized_path =
|
||||
Path::IsAbsolute(path) ? Path::Canonicalize(path) : Path::Canonicalize(Path::Combine(root, path));
|
||||
if (canonicalized_path.length() < root.length() || // Length has to be longer (a file),
|
||||
!canonicalized_path.starts_with(root) || // and start with the host root,
|
||||
canonicalized_path[root.length()] != FS_OSPATH_SEPARATOR_CHARACTER) // and we can't access a sibling.
|
||||
{
|
||||
ERROR_LOG("Denying access to path outside of PCDrv directory. Requested path: '{}', "
|
||||
"Resolved path: '{}', Root directory: '{}'",
|
||||
path, root, canonicalized_path);
|
||||
path, canonicalized_path, root);
|
||||
canonicalized_path.clear();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user