fix(libkernel_sys): reject parent-directory components in symlink targets

symlink_nid_postfix blocked absolute targets but accepted relative
targets containing '..' unchecked. The target is stored verbatim and the
host OS follows it when the link is later opened through the guest path
resolver, so symlink("../../../../..", "e") followed by
sceKernelOpen("e/etc/passwd", ...) reads host files outside the guest
root. Reject any '..' component, mirroring the absolute-target handling
above it.
This commit is contained in:
valenciana-nc committed 2026-10-18 21:09:38 +00:00
1 parent 2d7619cf99
commit 7408e55478
1 file changed
+6
+6
View File
@@ -375,6 +375,12 @@ int APS5_VABI symlink_nid_postfix(const char* target, const char* created) {
NotImplemented_nid_no_patch("symlink: absolute targets");
return -1;
}
for (const auto& part : std::filesystem::path(target)) {
if (part == "..") {
NotImplemented_nid_no_patch("symlink: parent-directory targets");
return -1;
}
}
std::filesystem::path native;
if (const int error = ResolvePathError_nid_no_patch(created, native)) return static_cast<int>(Fail(error));
std::error_code error;