RFR: 8306882: (fs) Path.toRealPath(LinkOption.NOFOLLOW_LINKS) fails when "../../" follows a link
Andrey Turbanov
aturbanov at openjdk.org
Thu Aug 24 07:00:32 UTC 2023
On Wed, 23 Aug 2023 01:09:16 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:
> Modify `Path.toRealPath` such that it does not collapse links such as "link/.." or "link/../.." when `LinkOption.NOFOLLOW_LINKS` is specified or, in some cases, not.
src/java.base/windows/classes/sun/nio/fs/WindowsLinkSupport.java line 211:
> 209: // full path manually derived in the process.
> 210: String fullpath = null;
> 211: if (path.contains("..")) {
I suggest to extract code for this case to a separate method. `sun.nio.fs.WindowsLinkSupport#getRealPath` is already too big.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/15397#discussion_r1303886682
More information about the nio-dev
mailing list