From b1b996b243df6d9925392328c76d5ddc1fd47adf Mon Sep 17 00:00:00 2001 From: MarcZX100 Date: Sun, 11 Oct 2026 10:22:12 +0000 Subject: [PATCH] fix(libkernel): reject empty sceKernelOpen paths --- core/libs/prx/libkernel/File/src/Open.cpp | 1 + core/libs/tests/GuestFilesystem.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/core/libs/prx/libkernel/File/src/Open.cpp b/core/libs/prx/libkernel/File/src/Open.cpp index ebdc6c064..ad358c273 100644 --- a/core/libs/prx/libkernel/File/src/Open.cpp +++ b/core/libs/prx/libkernel/File/src/Open.cpp @@ -135,6 +135,7 @@ static int SceIoErrorFromErrno(int error) { extern "C" { int APS5_VABI sceKernelOpen(const char* path, int flags, std::uint16_t mode) { + if (path != nullptr && *path == '\0') return SCE_KERNEL_ERROR_ENOENT; APS5_LOG_OUT("path=%s flags=0x%X nativeFlags=0x%X mode=0%o", path, flags, MapFlags(flags), mode); if (path != nullptr && File::IsRandomDevicePath(path)) { if ((flags & SCE_KERNEL_O_ACCMODE) != SCE_KERNEL_O_RDONLY) throw std::runtime_error(std::string(__func__) + ": writing to " + path + " is not implemented"); diff --git a/core/libs/tests/GuestFilesystem.cpp b/core/libs/tests/GuestFilesystem.cpp index 4f2710df7..67ae207bc 100644 --- a/core/libs/tests/GuestFilesystem.cpp +++ b/core/libs/tests/GuestFilesystem.cpp @@ -422,6 +422,7 @@ int main() { Require(sceKernelOpen(missingName.c_str(), 0x20000, 0) == static_cast(0x80020002u)); Require(open_nid_postfix("", 0, 0) == -1 && *__error_nid_postfix() == 2); Require(_open_nid_postfix("", 0) == -1 && *__error_nid_postfix() == 2); + Require(sceKernelOpen("", 0, 0) == static_cast(0x80020002u)); Require(open_nid_postfix(nullptr, 0, 0) == -1 && *__error_nid_postfix() == 14); Require(_open_nid_postfix(nullptr, 0) == -1 && *__error_nid_postfix() == 14); Require(rmdir_nid_postfix(rootName.c_str()) == -1 && *__error_nid_postfix() == 66);