Merge pull request #3428 from MarcZX100/codex/fix-libkernel-open-empty-path-3308

fix(libkernel): reject empty sceKernelOpen paths
This commit is contained in:
Adrià 2026-10-11 13:55:48 +02:00 committed by GitHub
commit c253de1165
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 0 deletions

View File

@ -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");

View File

@ -440,6 +440,7 @@ int main() {
Require(sceKernelOpen(missingName.c_str(), 0x20000, 0) == static_cast<int>(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<int>(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);