mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-05 09:39:58 +00:00
Revert "IOS HLE: Prevent accessing host file system"
This reverts commit 141f3bfb3acee73569486258c21e4ed34fc32327. The implementation of getting absolute paths wasn't working on non-Windows systems, which is a huge problem for IOS HLE.
This commit is contained in:
parent
c84ab13e81
commit
de355a8521
@ -5,7 +5,6 @@
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
@ -31,6 +30,7 @@
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <libgen.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
@ -712,19 +712,6 @@ std::string GetBundleDirectory()
|
||||
}
|
||||
#endif
|
||||
|
||||
std::string GetAbsolutePath(const std::string& path)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
wchar_t absolute_path[_MAX_PATH];
|
||||
wchar_t* result = _wfullpath(absolute_path, UTF8ToTStr(path).c_str(), _MAX_PATH);
|
||||
return result ? TStrToUTF8(result) : "";
|
||||
#else
|
||||
char absolute_path[MAX_PATH + 1];
|
||||
char* result = realpath(path.c_str(), absolute_path);
|
||||
return result ? result : "";
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string& GetExeDirectory()
|
||||
{
|
||||
static std::string DolphinPath;
|
||||
|
@ -133,10 +133,6 @@ std::string CreateTempDir();
|
||||
// Get a filename that can hopefully be atomically renamed to the given path.
|
||||
std::string GetTempFilenameForAtomicWrite(const std::string& path);
|
||||
|
||||
// Converts the given path into an absolute path.
|
||||
// An empty string is returned if an error occurs.
|
||||
std::string GetAbsolutePath(const std::string& path);
|
||||
|
||||
// Gets a set user directory path
|
||||
// Don't call prior to setting the base user directory
|
||||
const std::string& GetUserPath(unsigned int dir_index);
|
||||
|
@ -10,8 +10,6 @@
|
||||
#include "Common/ChunkFile.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/FileUtil.h"
|
||||
#include "Common/Logging/Log.h"
|
||||
#include "Common/MsgHandler.h"
|
||||
#include "Common/NandPaths.h"
|
||||
#include "Core/HW/Memmap.h"
|
||||
#include "Core/IPC_HLE/WII_IPC_HLE.h"
|
||||
@ -25,6 +23,8 @@ static std::map<std::string, std::weak_ptr<File::IOFile>> openFiles;
|
||||
// This is used by several of the FileIO and /dev/fs functions
|
||||
std::string HLE_IPC_BuildFilename(std::string path_wii)
|
||||
{
|
||||
std::string path_full = File::GetUserPath(D_SESSION_WIIROOT_IDX);
|
||||
|
||||
// Replaces chars that FAT32 can't support with strings defined in /sys/replace
|
||||
for (auto& replacement : replacements)
|
||||
{
|
||||
@ -32,30 +32,9 @@ std::string HLE_IPC_BuildFilename(std::string path_wii)
|
||||
path_wii.replace(j, 1, replacement.second);
|
||||
}
|
||||
|
||||
const std::string root_path = File::GetUserPath(D_SESSION_WIIROOT_IDX);
|
||||
const std::string full_path = root_path + path_wii;
|
||||
path_full += path_wii;
|
||||
|
||||
const std::string absolute_root_path = File::GetAbsolutePath(root_path);
|
||||
const std::string absolute_full_path = File::GetAbsolutePath(full_path);
|
||||
if (absolute_root_path.empty() || absolute_full_path.empty())
|
||||
{
|
||||
PanicAlert("IOS HLE: Couldn't get an absolute path; the root directory will be returned. "
|
||||
"This will most likely lead to failures.");
|
||||
return root_path;
|
||||
}
|
||||
|
||||
if (path_wii.empty() || path_wii[0] != '/' ||
|
||||
absolute_full_path.compare(0, absolute_root_path.size(), absolute_root_path) != 0)
|
||||
{
|
||||
// Prevent the emulated system from accessing files that aren't in the NAND directory.
|
||||
// (Emulated software that tries to exploit Dolphin might access a path like "/../..".)
|
||||
WARN_LOG(WII_IPC_FILEIO,
|
||||
"The emulated software tried to access a file outside of the NAND directory: %s",
|
||||
absolute_full_path.c_str());
|
||||
return root_path;
|
||||
}
|
||||
|
||||
return full_path;
|
||||
return path_full;
|
||||
}
|
||||
|
||||
void HLE_IPC_CreateVirtualFATFilesystem()
|
||||
|
Loading…
x
Reference in New Issue
Block a user