mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-12-02 18:53:58 +01:00
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:
1 parent
779cae6232
commit
0eef5d0164
4 files changed
+19
-23
No files matched your search
@@ -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;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user