Permalink
Browse files

Savedata: Also validate icon/subdata size.

  • Loading branch information...
unknownbrackets committed Aug 11, 2018
1 parent c0ccc94 commit b64bb2e8ce93a5fc9566e73bb74827a7664c97fa
Showing with 11 additions and 0 deletions.
  1. +11 −0 Core/Dialog/SavedataParam.cpp
@@ -366,6 +366,17 @@ int SavedataParam::Save(SceUtilitySavedataParam* param, const std::string &saveD
ERROR_LOG_REPORT(SCEUTILITY, "Savedata buffer overflow: %d / %d", param->dataSize, param->dataBufSize);
return SCE_UTILITY_SAVEDATA_ERROR_RW_BAD_PARAMS;
}
auto validateSize = [](const PspUtilitySavedataFileData &data) {
if (data.buf.IsValid() && data.bufSize < data.size) {
ERROR_LOG_REPORT(SCEUTILITY, "Savedata subdata buffer overflow: %d / %d", data.size, data.bufSize);
return false;
}
return true;
};
if (!validateSize(param->icon0FileData) || !validateSize(param->icon1FileData) || !validateSize(param->pic1FileData) || !validateSize(param->snd0FileData)) {
return SCE_UTILITY_SAVEDATA_ERROR_RW_BAD_PARAMS;
}
if (param->secureVersion > 3) {
ERROR_LOG_REPORT(SCEUTILITY, "Savedata version requested on save: %d", param->secureVersion);
return SCE_UTILITY_SAVEDATA_ERROR_SAVE_PARAM;

0 comments on commit b64bb2e

Please sign in to comment.