From 49b0306b1dba43c2f966c96667042b2f5ac22988 Mon Sep 17 00:00:00 2001 From: Elad <18193363+elad335@users.noreply.github.com> Date: Tue, 14 Jul 2026 19:55:21 +0300 Subject: [PATCH] sys_fs: Secure ENOTDIR for sys_fs_stat --- rpcs3/Emu/Cell/lv2/sys_fs.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/rpcs3/Emu/Cell/lv2/sys_fs.cpp b/rpcs3/Emu/Cell/lv2/sys_fs.cpp index 771ff2e1a0..cf3e4a5043 100644 --- a/rpcs3/Emu/Cell/lv2/sys_fs.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_fs.cpp @@ -1071,7 +1071,7 @@ lv2_file::open_raw_result_t lv2_file::open_raw(const std::string& local_path, s3 return {CELL_ENOTDIR}; } - fmt::throw_exception("unknown error %s", error); + fmt::throw_exception("unknown error %s (local=%s)", error, local_path); } } } @@ -1784,11 +1784,17 @@ error_code sys_fs_stat(ppu_thread& ppu, vm::cptr path, vm::ptr return { CELL_ENOTDIR, path }; } - fmt::throw_exception("unknown error %s", error); + fmt::throw_exception("unknown error %s (local=%s)", error, local_path); } } } + if (ends_with_delim_dot_or_dotdot(vpath) && !info.is_directory) + { + // If ending with "/.", it must be a directory + return { CELL_ENOTDIR, path }; + } + lock.unlock(); ppu.check_state();