fix(libc): resolve ".." in guest paths against the directory before it #3892
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3892"
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 renzipego-cpu on 2026-10-11T18:55:21Z.
Carries the branch from #3117 (
milescoviello:fix/dotdot-path-resolution@98a5a999), rebased onto current main and rebuilt here. Fixes #3117.What
Resolveinlibc/src/General.cppnormalizes the guest path withlexically_normal()before the host sees it, so the component before..is never checked. Onmain(Linux), withdd/filea file anddd/victima directory:stat("dd/missing/../file")andopen(...)succeed;stat("dd/file/..")succeeds;unlink("dd/missing/../file")deletesdd/file;rmdir("dd/missing/../victim")deletesdd/victim.FreeBSD's
lookup()(sys/kern/vfs_lookup.c) resolves..withVOP_LOOKUPin the directory reached so far, so these fail withENOENT(missing component) orENOTDIR(file component), and POSIX pathname resolution (XBD 4.13) says the same. With this change,..is still collapsed when the path before it is an existing directory (aliases and case-insensitive matching keep behaving as before); otherwise the rest of the path reaches the host unchanged and reports the right error.Tested
Windows 11, MinGW-w64 GCC 15.2.0 (WinLibs r7), Ninja, Release,
BUILD_TESTING=ON, full build includinglibs:guest_path_caseandguest_realpathpass on the rebased branch. (guest_filesystemaborts on this machine without Windows Developer Mode for symlinks — same on cleanmain.)python tools/check_conventions.py --base upstream/mainpasses; no new test registration needed (the branch extends the existingGuestFilesystem.cppcases).Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-11T18:56:27Z.
Thanks for carrying it, @renzipego-cpu. A heads-up so it isn't reviewed twice: #3485 (@santhoshkumar-dev) already carries this same commit as its first one (21d1698c, identical patch), together with the Windows half of #3117, and its checks pass. Either way is fine by me; just pointing out the overlap.
Imported from boykopovar/AnyPS5. Originally posted by renzipego-cpu on 2026-10-11T19:01:48Z.
ok thanks
Imported from boykopovar/AnyPS5. Originally posted by santhoshkumar-dev on 2026-10-11T19:43:42Z.
+1
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-11T23:59:12Z.
Closing: #3485 is merged and has this same commit as its first one, together with the Windows half of #3117.
You're welcome to reopen this if you think it was closed by mistake or the situation changes.
Pull request closed