fix(libc): fail an oversized guest path name with ENAMETOOLONG #8164
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8164"
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-20T01:03:17Z.
What
stat,open,mkdir,unlink,rmdir,rename,accessand the other calls that resolve a guest path answerENOENT(andrenameEIO) for a path name that FreeBSD refuses as too long, because the resolved host path does not exist. FreeBSD 11.4'snamei(vfs_lookup.c) fails a path component aboveNAME_MAX(255 bytes) and a path ofMAXPATHLEN(1024 bytes including the terminating NUL) withENAMETOOLONG(63).Resolve()inGeneral.cpp(behindResolvePath_nid_no_patch) now checks the whole path (1024 bytes) on the guest string before resolving it, and a component above 255 bytes only when every component before it exists and is a directory (nameiresolves in order, so a missing directory earlier in the path still answersENOENT). Both throw afilesystem_errorwithfilename_too_long;FilesystemErroralready maps that to 63 andResolvePathError_nid_no_patch, which the kernel calls use, turns it into the errno. A name of exactly 255 bytes is not affected.chflagsresolved its path with the throwing form and without a try block, so a long name would have ended the title once this check exists. A second commit makes it useResolvePathError_nid_no_patchlikechmod;guest_path_name_lengthhas achflagscase for it. The third commit adds a technical debt entry.Limits (in the debt entry for libc): the host's own limit still applies below these numbers (on Windows a path whose host form is longer than
MAX_PATHfails withENOENT); a backslash counts as a separator for the component length (the guest resolver turns it into/), while FreeBSD treats it as a name character;sceNgs2ParseWaveformFileresolves without a try block, so a long component ends in an uncaughtfilesystem_errorthere where a missing file ended in aruntime_error(both end the title); a path through a regular file is not alwaysENOTDIR.No title evidence: found by calling the file functions with oversized names. This is FreeBSD conformance. Replaces #5006 (closed), rebased on current
main.Fixes #8163
Tested
Windows 10 (19045), MinGW-w64 GCC 15.2.0, Release, on
upstream/main+ these commits:guest_path_name_length:Exit code 0xc0000409without the changes toGeneral.cppandStdio.cpp, passes with them.guest_filesystem,guest_fopen_long_host_path,guest_path_case,guest_path_drive_component,guest_working_directoryandguest_directorypass (7 of 7 with the new test).python tools/check_conventions.py --base upstream/main: passes (a warning about the length of the debt entry).pr_overlap(checkedmerge-treeand aghsearch instead).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-20T01:19:46Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/libs/prx/libkernel/File/src/Stdio.cppL620-626Some 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/libkernel/CMakeLists.txtcore/libs/prx/libc/src/General.cppcore/libs/prx/libkernel/CMakeLists.txtcore/libs/prx/libkernel/File/src/Stdio.cppdocs/dev/debt/libc.mddocs/dev/debt/libc.mdcore/libs/prx/libkernel/CMakeLists.txtcore/libs/prx/libc/src/General.cppcore/libs/prx/libkernel/CMakeLists.txtdocs/dev/debt/libc.mdcore/libs/prx/libkernel/CMakeLists.txtdocs/dev/debt/libc.mddocs/dev/debt/libc.mdcore/libs/prx/libc/src/General.cppcore/libs/prx/libkernel/File/src/Stdio.cppcore/libs/prx/libkernel/CMakeLists.txtcore/libs/prx/libkernel/File/src/Stdio.cppdocs/dev/debt/libc.mdcore/libs/prx/libkernel/File/src/Stdio.cppcore/libs/prx/libkernel/CMakeLists.txtcore/libs/prx/libc/src/General.cppcore/libs/prx/libkernel/CMakeLists.txtcore/libs/prx/libkernel/File/src/Stdio.cppcore/libs/prx/libc/src/General.cppcore/libs/prx/libkernel/CMakeLists.txtcore/libs/prx/libkernel/File/src/Stdio.cppdocs/dev/debt/libc.mddocs/dev/debt/libc.mddocs/dev/debt/libc.mddocs/dev/debt/libc.mddocs/dev/debt/libc.md