libc: rename checks the destination argument before the source, where FreeBSD looks up the source first; fix branch ready #8356
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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:29Z.
On Windows,
rename,_renameandsceKernelRenamereject a NULL, empty or.-ending destination before they look at the source. FreeBSD 11.4 resolves the source first (kern_renameat:namei(&fromnd)returns the source's error before the destination is looked at,namei(&tond)follows at :3232). Sorename(missing, NULL)andrename(missing, ".")fail withENOENTthere, where we returnEFAULTandEINVAL;rename(".", NULL)andrename(".", "")fail withEINVAL.Cause.
RenameGuestPath_nid_no_patchtests both arguments for NULL, empty and a dot component before it resolves either path, andsceKernelRenamerejects a NULL destination itself.Observed on
main01e5f8f199, Windows 10 (10.0.19045), WinLibs GCC 15.2.0 r7, Release: the added assertions inguest_filesystemabort onmain(exit code 0xc0000409) and pass with the fix. I did not run the individual calls againstmain; the results above come from reading the source. I have not found a title that stops on this; it came out of reading the libkernel and libc file calls against the FreeBSD 11.4 sources.Fix, ready to cherry-pick.
xXPBSXx:fix/libc-rename-source-first(308848e1a6, one commit onmain7602dde042, three files, +25/-4). The source is checked first (NULL, empty, dot component); a bad destination is then reported only if the source exists, otherwise the source'sENOENTorENOTDIRwins. Valid arguments and the existing destination errors behave as before.AI-assisted (Claude Code).