fix(libc): resolve the rename source before the destination argument #8358
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8358"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-20T10:58:51Z.
What
rename,_renameandsceKernelRenamechecked the destination (NULL, empty, dot component) before they looked at the source. FreeBSD 11.4kern_renameat(vfs_syscalls.c:3217) looks up the source first and returns its error before it touches the destination (:3232). The source is now checked first (NULL, empty, dot component, then existence and non-directory prefix); a NULL, empty or dot destination is reported only for a source that exists.sceKernelRenameno longer rejects a NULL destination on its own.Fixes #8356
Tested
Windows 10 (19045), WinLibs GCC 15.2.0 r7, Release, on
main7602dde042+ this commit (308848e1a6); the run without the change was made onmain01e5f8f199:guest_filesystem: aborts with exit code 0xc0000409 without the changes toRename.cppandStdio.cpp, passes with them, 3 of 3 runs.guest_rename_dot,guest_kernel_renameandguest_posix_filesystempass, 3 of 3 runs each.python tools/check_conventions.py --base upstream/mainandgit diff --checkpass.Checklist
main; no other open PR implements the same functions.mdfiles or images added to the repositoryAI-assisted (Claude Code).
🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-20T11:07:40Z.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/libs/prx/libc/src/Rename.cppcore/libs/prx/libkernel/File/src/Stdio.cppcore/libs/tests/GuestFilesystem.cppcore/libs/tests/GuestPosixScalarIo.cppcore/libs/prx/libkernel/File/src/Stdio.cppcore/libs/prx/libkernel/File/src/Stdio.cppcore/libs/tests/GuestPosixScalarIo.cppcore/libs/prx/libkernel/File/src/Stdio.cppcore/libs/prx/libc/src/Rename.cppcore/libs/prx/libkernel/File/src/Stdio.cppImported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-20T11:44:42Z.
Thanks. The new order matches FreeBSD's
kern_renameat: the source lookup comes first, and a NULL destination only fails inside the secondnamei. One existing test still expects the old order, so from reading the code (we haven't run it yet) it should now fail:core/libs/tests/GuestPosixScalarIo.cpp:172:"src"is a relative path that doesn't exist in the test's working directory (ctest runs it inbuild/core/libs). With this change the missing source is reported first, sosceKernelRenamereturns0x80020002andguest_posix_scalar_ioaborts on Linux and Windows. Could you update that line to expect ENOENT, or rename an existing file tonullptrif you want to keep the EFAULT case there?Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-20T12:31:21Z.
Thanks for catching this, @oneandonlydean, and sorry for the broken test.
GuestPosixScalarIo.cpp:172still expectedEFAULTforsceKernelRename("src", nullptr), butsrcdoes not exist in that test, and with this change the source's error comes first, as in FreeBSD'skern_renameat, so it now returnsENOENT. I had built only the rename tests I knew of instead of searching the tests for every caller.Pushed
0a0910c54d: the expectation on that line is now0x80020002(ENOENT);EFAULTfor a NULL destination is still covered where the source exists (GuestFilesystem.cpp,GuestKernelRename.cpp).I then found every test in
core/libs/teststhat callsrename,_renameorsceKernelRename, built them and ran each withcteston Windows 10 (19045, WinLibs GCC 15.2.0 r7, Release):guest_posix_scalar_io,guest_kernel_sys,guest_kernel_sync,guest_kqueue,guest_path_name_length,guest_path_case,file_streams,guest_filesystem,guest_rename_dotandguest_kernel_renameall pass. I did not run Linux.AI-assisted (Claude Code).