mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-13 09:39:33 +01:00
sceNetAdhoc: Don't fault on NULL pointers the PSP accepts
sceNetAdhocPdpSend with NULL data and a length of 0, sceNetAdhocPdpRecv with a NULL sender MAC or port, and sceNetAdhocPtpSend with a NULL length pointer all raised a memory exception before the call ran, which stopped the game. On a PSP the first two succeed and the last returns INVALID_ARG (net/adhoc/pdp and net/adhoc/ptp in pspautotests). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6056ec419a
commit
a4fe8e8f17
2 files changed
+6
-3
No files matched your search
@@ -922,12 +922,15 @@ template<auto func> void WrapI_ICI(MIPSState *mips) {
|
||||
}
|
||||
|
||||
template<auto func> void WrapI_IVVVVUI(MIPSState *mips) {
|
||||
u32 retval = HLECall<int(int, void *, void *, void *, void *, u32, int), func>(mips, PARAM(0), Memory::GetPointerWriteOrException(PARAM(1)), Memory::GetPointerWriteOrException(PARAM(2)), Memory::GetPointerWriteOrException(PARAM(3)), Memory::GetPointerWriteOrException(PARAM(4)), PARAM(5), PARAM(6) );
|
||||
// Any of the pointers may be NULL (sceNetAdhocPdpRecv takes NULL for the sender), so don't fault on it.
|
||||
auto ptr = [](u32 addr) -> void * { return addr ? Memory::GetPointerWriteOrException(addr) : nullptr; };
|
||||
u32 retval = HLECall<int(int, void *, void *, void *, void *, u32, int), func>(mips, PARAM(0), ptr(PARAM(1)), ptr(PARAM(2)), ptr(PARAM(3)), ptr(PARAM(4)), PARAM(5), PARAM(6) );
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
template<auto func> void WrapI_ICUVIII(MIPSState *mips) {
|
||||
u32 retval = HLECall<int(int, const char *, u32, void *, int, int, int), func>(mips, PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2), Memory::GetPointerWriteOrException(PARAM(3)), PARAM(4), PARAM(5), PARAM(6));
|
||||
// The buffer may be NULL (sceNetAdhocPdpSend with a length of 0 is fine with that), so don't fault on it.
|
||||
u32 retval = HLECall<int(int, const char *, u32, void *, int, int, int), func>(mips, PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2), PARAM(3) ? Memory::GetPointerWriteOrException(PARAM(3)) : nullptr, PARAM(4), PARAM(5), PARAM(6));
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
|
||||
@@ -5390,7 +5390,7 @@ static int sceNetAdhocPtpListen(MIPSState *mips, const char *srcmac, int sport,
|
||||
static int sceNetAdhocPtpSend(MIPSState *mips, int id, u32 dataAddr, u32 dataSizeAddr, int timeout, int flag) {
|
||||
DEBUG_LOG(Log::sceNet, "sceNetAdhocPtpSend(%d,%08x,%08x,%d,%d) at %08x", id, dataAddr, dataSizeAddr, timeout, flag, mips->pc);
|
||||
|
||||
int * len = (int *)Memory::GetPointerOrException(dataSizeAddr);
|
||||
int * len = dataSizeAddr ? (int *)Memory::GetPointerOrException(dataSizeAddr) : nullptr;
|
||||
const char * data = Memory::GetCharPointer(dataAddr);
|
||||
// Library is initialized
|
||||
if (netAdhocInited) {
|
||||
|
||||
Reference in new issue
Block a user