diff options
| author | JosJuice <josjuice@gmail.com> | 2016-11-24 15:53:23 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-11-24 15:53:23 +0100 |
| commit | 9bfea4a0f2f8533ebedeedf809c29bcdb2f4200c (patch) | |
| tree | 44582d689a5d18b4e40b266182315d03b693a055 /Source/Core/Common | |
| parent | b6f9bdf16bf29a49c6fcf12b07f144d2ccbabbba (diff) | |
| parent | 141f3bfb3acee73569486258c21e4ed34fc32327 (diff) | |
Merge pull request #4447 from JosJuice/hthh-hle-issues
Fix exploitable HLE problems reported by hthh
Diffstat (limited to 'Source/Core/Common')
| -rw-r--r-- | Source/Core/Common/FileUtil.cpp | 15 | ||||
| -rw-r--r-- | Source/Core/Common/FileUtil.h | 4 |
2 files changed, 18 insertions, 1 deletions
diff --git a/Source/Core/Common/FileUtil.cpp b/Source/Core/Common/FileUtil.cpp index e761f3ade1..acf154f81a 100644 --- a/Source/Core/Common/FileUtil.cpp +++ b/Source/Core/Common/FileUtil.cpp @@ -5,6 +5,7 @@ #include <algorithm> #include <cstddef> #include <cstdio> +#include <cstdlib> #include <cstring> #include <fcntl.h> #include <limits.h> @@ -30,7 +31,6 @@ #include <dirent.h> #include <errno.h> #include <libgen.h> -#include <stdlib.h> #include <unistd.h> #endif @@ -712,6 +712,19 @@ 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; diff --git a/Source/Core/Common/FileUtil.h b/Source/Core/Common/FileUtil.h index f4a20f623d..cc0ec5a651 100644 --- a/Source/Core/Common/FileUtil.h +++ b/Source/Core/Common/FileUtil.h @@ -133,6 +133,10 @@ 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); |
