symlink accepts a target of 1024 bytes or more instead of failing with ENAMETOOLONG #8722
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-20T22:24:42Z.
symlink_nid_postfix(core/libs/prx/libkernel_sys/Export.cpp) has no length check on the target. FreeBSD 11.4kern_symlinkatcopies the target withcopyinstr(path1, syspath, MAXPATHLEN, NULL)(sys/kern/vfs_syscalls.c:1490) before it looks up the link name;MAXPATHLENisPATH_MAX= 1024 (sys/sys/param.h:280, sys/sys/syslimits.h:63). A target of 1024 bytes or more therefore fails with ENAMETOOLONG (63). Probe:symlink_nid_postfix(std::string(1100,'a').c_str(), "<root>/link")returned -1 with errno 1 on Windows without symlink privilege (and would try to create the link with it); expected -1 / 63.AI-assisted (Claude Code).
Fix branch: https://github.com/xXPBSXx/AnyPS5/tree/fix/symlink-target-too-long
Imported from boykopovar/AnyPS5. Originally posted by Filip722 on 2026-10-21T09:45:58Z.
Confirmed on Linux: main successfully creates links with 1024- and 1100-byte targets. This is more than an error-mapping difference caused by Windows symlink privilege.
Tested unchanged upstream
mainb5d763770a8e932b35db9bea1c415e7e0ac50a22in a separate validation checkout. Environment: Debian GNU/Linux 13.7 (trixie), x86-64, kernel7.2.9-x64v3-xanmod1, AMD Ryzen 5 7640HS, GCC/G++ 15.2.0, CMake 3.31.6/Ninja. Full project configuration:Release,BUILD_TESTING=ON,ANYPS5_RELINKER_ONLY=OFF,ANYPS5_USE_SYSTEM_DEPS=OFF; rebuiltlibc,libkernelandlibkernel_sys. Temporary probes linked directly to these freshly built, unpatched runtime libraries, as the repository runtime tests do. No production source changes.Reproduction: from a scratch directory on Linux
tmpfs, created a relative guest directorysymlink-fixtures-guest-readlinkand, for each length below, called:Each link had a distinct name. The target need not exist; the check concerns storing its bytes, not resolving it. Relative link paths ensure this exercises the guest sandbox resolver correctly.
symlink_nid_postfixresultreadlinkresultHost
std::filesystem::read_symlinkindependently returned the same full bytes. Native Linuxsymlinkcontrols also accepted all three lengths. The reported FreeBSD-style 1024-byte guest bound therefore needs enforcement in the guest adapter; this host filesystem does not impose that boundary. Main'ssymlink_nid_postfixcurrently checks neither the target length nor that bound before creating the link. Errno after successful calls is intentionally not interpreted.Existing
guest_kernel_syspasses on this build, but does not test these target lengths on main.Scope: reproduces the missing bound on unchanged main and confirms 1023-byte creation is available here. I did not apply/test #8723. Only relative all-ASCII targets and a tmpfs scratch directory; no console, Windows, GPU or title execution tested.
AI-assisted: yes (Codex); I am responsible for the reported investigation and results.