Skip to content

Commit

Permalink
Return an error for invalid savedata sizes.
Browse files Browse the repository at this point in the history
  • Loading branch information
unknownbrackets committed Mar 24, 2014
1 parent b589d3b commit fc833ad
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Core/Dialog/PSPOskDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ int PSPOskDialog::Init(u32 oskPtr) {
oskParams = oskPtr;
if (oskParams->base.size != sizeof(SceUtilityOskParams))
{
ERROR_LOG(SCEUTILITY, "sceUtilityOskInitStart: invalid size (%d)", oskParams->base.size);
ERROR_LOG_REPORT(SCEUTILITY, "sceUtilityOskInitStart: invalid size %d", oskParams->base.size);
return SCE_ERROR_UTILITY_INVALID_PARAM_SIZE;
}
// Also seems to crash.
Expand Down
10 changes: 10 additions & 0 deletions Core/Dialog/PSPSaveDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ const static float FONT_SCALE = 0.55f;
const static int SAVEDATA_INIT_DELAY_US = 200000;
const static int SAVEDATA_SHUTDOWN_DELAY_US = 2000;

// These are the only sizes which are allowed.
// TODO: We should test what the different behavior is for each.
const static int SAVEDATA_DIALOG_SIZE_V1 = 1480;
const static int SAVEDATA_DIALOG_SIZE_V2 = 1500;
const static int SAVEDATA_DIALOG_SIZE_V3 = 1536;


PSPSaveDialog::PSPSaveDialog()
: PSPDialog()
Expand All @@ -59,6 +65,10 @@ int PSPSaveDialog::Init(int paramAddr)
int size = Memory::Read_U32(requestAddr);
memset(&request, 0, sizeof(request));
// Only copy the right size to support different save request format
if (size != SAVEDATA_DIALOG_SIZE_V1 && size != SAVEDATA_DIALOG_SIZE_V2 && size != SAVEDATA_DIALOG_SIZE_V3) {
ERROR_LOG_REPORT(SCEUTILITY, "sceUtilitySavedataInitStart: invalid size %d", size);
return SCE_ERROR_UTILITY_INVALID_PARAM_SIZE;
}
Memory::Memcpy(&request, requestAddr, size);
Memory::Memcpy(&originalRequest, requestAddr, size);

Expand Down

0 comments on commit fc833ad

Please sign in to comment.