From abcdff6a50ee46935c4e860ade21f90dd9652c74 Mon Sep 17 00:00:00 2001 From: Stefanos Kornilios Mitsis Poiitidis Date: Thu, 10 Sep 2020 20:28:16 +0300 Subject: [PATCH] EmulatedFiles: Don't crash on too long paths --- .../Source/Interface/HLE/EmulatedFiles/EmulatedFiles.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/External/FEXCore/Source/Interface/HLE/EmulatedFiles/EmulatedFiles.cpp b/External/FEXCore/Source/Interface/HLE/EmulatedFiles/EmulatedFiles.cpp index bc99c4c63..dce4f3e50 100644 --- a/External/FEXCore/Source/Interface/HLE/EmulatedFiles/EmulatedFiles.cpp +++ b/External/FEXCore/Source/Interface/HLE/EmulatedFiles/EmulatedFiles.cpp @@ -612,7 +612,12 @@ namespace FEXCore::EmulatedFile { } int32_t EmulatedFDManager::OpenAt(int dirfs, const char *pathname, int flags, uint32_t mode) { - string cpath = std::filesystem::exists(pathname) ? std::filesystem::canonical(pathname) + std::error_code ec; + bool exists = std::filesystem::exists(pathname, ec); + if (ec) { + return -1; + } + string cpath = exists ? std::filesystem::canonical(pathname) : std::filesystem::path(pathname).lexically_normal(); // *Note: this doesn't transform to absolute if (EmulatedMap.find(cpath) == EmulatedMap.end()) {