Permalink
Browse files

Savedata: Add validation on secureVersion param.

  • Loading branch information...
unknownbrackets committed Jun 24, 2018
1 parent aad6377 commit 46d7ead78132d57536b361271d527ebd0ec6cc95
Showing with 19 additions and 2 deletions.
  1. +18 −1 Core/Dialog/SavedataParam.cpp
  2. +1 −1 Core/Dialog/SavedataParam.h
@@ -362,6 +362,16 @@ int SavedataParam::Save(SceUtilitySavedataParam* param, const std::string &saveD
if (!param) {
return SCE_UTILITY_SAVEDATA_ERROR_SAVE_MS_NOSPACE;
}
if (param->secureVersion > 3) {
ERROR_LOG_REPORT(SCEUTILITY, "Savedata version requested on save: %d", param->secureVersion);
return SCE_UTILITY_SAVEDATA_ERROR_SAVE_PARAM;
} else if (param->secureVersion != 0) {
if (param->secureVersion != 1 && !HasKey(param)) {
ERROR_LOG_REPORT(SCEUTILITY, "Savedata version with missing key on save: %d", param->secureVersion);
return SCE_UTILITY_SAVEDATA_ERROR_SAVE_PARAM;
}
WARN_LOG_REPORT(SCEUTILITY, "Savedata version requested on save: %d", param->secureVersion);
}
std::string dirPath = GetSaveFilePath(param, GetSaveDir(param, saveDirName));
@@ -573,7 +583,14 @@ int SavedataParam::Load(SceUtilitySavedataParam *param, const std::string &saveD
}
int SavedataParam::LoadSaveData(SceUtilitySavedataParam *param, const std::string &saveDirName, const std::string &dirPath, bool secureMode) {
if (param->secureVersion != 0) {
if (param->secureVersion > 3) {
ERROR_LOG_REPORT(SCEUTILITY, "Savedata version requested: %d", param->secureVersion);
return SCE_UTILITY_SAVEDATA_ERROR_LOAD_PARAM;
} else if (param->secureVersion != 0) {
if (param->secureVersion != 1 && !HasKey(param)) {
ERROR_LOG_REPORT(SCEUTILITY, "Savedata version with missing key: %d", param->secureVersion);
return SCE_UTILITY_SAVEDATA_ERROR_LOAD_PARAM;
}
WARN_LOG_REPORT(SCEUTILITY, "Savedata version requested: %d", param->secureVersion);
}
u8 *data_ = param->dataBuf;
@@ -253,7 +253,7 @@ struct SceUtilitySavedataParam
u8 key[16];
s32_le secureVersion;
u32_le secureVersion;
s32_le multiStatus;
// Function 11 LIST

0 comments on commit 46d7ead

Please sign in to comment.