From bd7019eb9d89e16362eccb148fc3b266885de18b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 15 Jan 2024 12:02:58 +0100 Subject: [PATCH] Protect sceIoOpen against nullptr filenames --- Core/HLE/sceIo.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Core/HLE/sceIo.cpp b/Core/HLE/sceIo.cpp index 8102c84944..ef2ba44cbf 100644 --- a/Core/HLE/sceIo.cpp +++ b/Core/HLE/sceIo.cpp @@ -1555,6 +1555,11 @@ static FileNode *__IoOpen(int &error, const char *filename, int flags, int mode) static u32 sceIoOpen(const char *filename, int flags, int mode) { hleEatCycles(18000); + if (!filename) { + // Not tested on the PSP. + return hleLogError(SCEIO, SCE_KERNEL_ERROR_ERRNO_FILE_NOT_FOUND, "nullptr file not found"); + } + if (!__KernelIsDispatchEnabled()) { hleEatCycles(48000); return hleLogError(SCEIO, SCE_KERNEL_ERROR_CAN_NOT_WAIT, "dispatch disabled"); @@ -2190,6 +2195,10 @@ static u32 sceIoSetAsyncCallback(int id, u32 clbckId, u32 clbckArg) static u32 sceIoOpenAsync(const char *filename, int flags, int mode) { hleEatCycles(18000); + if (!filename) { + // Not tested on the PSP. + return hleLogError(SCEIO, SCE_KERNEL_ERROR_ERRNO_FILE_NOT_FOUND, "nullptr file not found"); + } // TODO: Use an internal method so as not to pollute the log? // Intentionally does not work when interrupts disabled.