RFR: 8306882: (fs) Path.toRealPath(LinkOption.NOFOLLOW_LINKS) fails when "../../" follows a link

Brian Burkhalter bpb at openjdk.org
Mon Aug 28 15:51:15 UTC 2023


On Thu, 24 Aug 2023 06:58:00 GMT, Andrey Turbanov <aturbanov 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.

Sounds like a good idea.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/15397#discussion_r1307599528


More information about the nio-dev mailing list