Use shared HasPathTraversal utility for savedata name validation

Replace the inline lambdas in the savedata dialog with the new
HasPathTraversal() helper in Core/Util/PathUtil.
This commit is contained in:
Henrik Rydgård committed 2026-08-01 13:16:21 +02:00
1 parent 779cae6232
commit 0eef5d0164
4 files changed
+19 -23

No files matched your search

+2 -8
View File
@@ -30,6 +30,7 @@
#include "Core/Dialog/SavedataParam.h"
#include "Core/Dialog/PSPSaveDialog.h"
#include "Core/FileSystems/MetaFileSystem.h"
#include "Core/Util/PathUtil.h"
#include "Core/HLE/sceIo.h"
#include "Core/HLE/sceKernelMemory.h"
#include "Core/HLE/sceChnnlsv.h"
@@ -1550,14 +1551,7 @@ int SavedataParam::SetPspParam(SceUtilitySavedataParam *param) {
// saveName entries become part of host filesystem paths; reject
// path separators and bare dot components (path traversal).
const std::string_view entry = StringViewFromFixedSizeField(saveNameListData[saveDataListCount]);
bool hasSeparator = false;
for (char c : entry) {
if (c == '/' || c == '\\') {
hasSeparator = true;
break;
}
}
if (hasSeparator || entry == "." || entry == "..") {
if (HasPathTraversal(entry)) {
ERROR_LOG(Log::sceUtility, "SavedataParam: invalid saveName in list: %s", std::string(entry).c_str());
return SCE_ERROR_UTILITY_INVALID_PARAM_SIZE;
}