From 5d78d81c003c9088732d7c622b488dc246cb6da9 Mon Sep 17 00:00:00 2001 From: Eladash Date: Fri, 13 Mar 2020 17:34:15 +0200 Subject: [PATCH] cellSaveData: Filter directory lists to allowed savedata directories Filters "." and "..", as well as possible wrong directories added by the user. --- rpcs3/Emu/Cell/Modules/cellSaveData.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rpcs3/Emu/Cell/Modules/cellSaveData.cpp b/rpcs3/Emu/Cell/Modules/cellSaveData.cpp index 562ef57951..dcc2cc29db 100644 --- a/rpcs3/Emu/Cell/Modules/cellSaveData.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSaveData.cpp @@ -107,12 +107,12 @@ static std::vector get_save_entries(const std::string& base_dir, // get the saves matching the supplied prefix for (auto&& entry : fs::dir(base_dir)) { - if (!entry.is_directory || entry.name == "." || entry.name == "..") + if (!entry.is_directory || sysutil_check_name_string(entry.name.c_str(), 1, CELL_SAVEDATA_DIRNAME_SIZE) != 0) { continue; } - if (entry.name.substr(0, prefix.size()) != prefix) + if (!entry.name.starts_with(prefix)) { continue; } @@ -591,7 +591,7 @@ static NEVER_INLINE error_code savedata_op(ppu_thread& ppu, u32 operation, u32 v // get the saves matching the supplied prefix for (auto&& entry : fs::dir(base_dir)) { - if (!entry.is_directory || entry.name == "." || entry.name == "..") + if (!entry.is_directory || sysutil_check_name_string(entry.name.c_str(), 1, CELL_SAVEDATA_DIRNAME_SIZE) != 0) { continue; }