Utility: Check request sizes like the firmware

InitStart sizes: Netconf and NpSignin accepted any size, then wrote
common.size bytes back from a 64-68 byte host struct, copying host memory
into PSP RAM. GamedataInstall looked for install files before checking the
size, and the HtmlViewer read options before checking the whole request was
in memory. All the dialogs now check the address, then the sizes
sceUtility_Driver accepts (utility/dialog/sizes), before anything else, as
the firmware does (a bad address is INVALID_ADDRESS), and write back no more
than the struct.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Henrik RydgårdandClaude Opus 5.5 committed 2026-09-25 12:50:41 -06:00
1 parent 9e69c1f9aa
commit 6dffcc91d2
11 files changed
+74 -80

No files matched your search

+7 -9
View File
@@ -56,18 +56,16 @@ int PSPMsgDialog::Init(unsigned int paramAddr) {
return SCE_ERROR_UTILITY_INVALID_STATUS;
}
const int check = CheckRequest(paramAddr, { SCE_UTILITY_MSGDIALOG_SIZE_V1, SCE_UTILITY_MSGDIALOG_SIZE_V2, SCE_UTILITY_MSGDIALOG_SIZE_V3 });
if (check < 0) {
return check;
}
if (!Memory::IsValid4AlignedAddress(paramAddr)) {
return SCE_KERNEL_ERROR_BAD_ARGUMENT; // untested
}
messageDialogAddr = paramAddr;
if (!Memory::IsValid4AlignedAddress(paramAddr)) {
// What to do?
return SCE_KERNEL_ERROR_BAD_ARGUMENT;
}
int size = Memory::ReadUnchecked_U32(paramAddr);
// The only sizes sceUtility_Driver accepts (utility/dialog/sizes).
if (size != SCE_UTILITY_MSGDIALOG_SIZE_V1 && size != SCE_UTILITY_MSGDIALOG_SIZE_V2 && size != SCE_UTILITY_MSGDIALOG_SIZE_V3) {
return SCE_ERROR_UTILITY_INVALID_PARAM_SIZE;
}
memset(&messageDialog, 0, sizeof(messageDialog));
// Only copy the right size to support different request format
Memory::Memcpy(&messageDialog,paramAddr,size);