8306882: (fs) Path.toRealPath(LinkOption.NOFOLLOW_LINKS) fails when "../../" follows a link#15397
8306882: (fs) Path.toRealPath(LinkOption.NOFOLLOW_LINKS) fails when "../../" follows a link#15397bplb wants to merge 5 commits intoopenjdk:masterfrom
Conversation
…../../" follows a link
|
👋 Welcome back bpb! A progress list of the required criteria for merging this PR into |
|
On Windows, the function |
Webrevs
|
| // to determine whether this would occur, and if so use the | ||
| // full path manually derived in the process. | ||
| String fullpath = null; | ||
| if (path.contains("..")) { |
There was a problem hiding this comment.
I suggest to extract code for this case to a separate method. sun.nio.fs.WindowsLinkSupport#getRealPath is already too big.
|
The changes to the Windows implementation of toRealPath(LinkOption.NOFOLLOW_LINKS) are going to take time to review. Once suggestion that would help set the groundwork is to move the toRealPath tests to their own JUnit test. It's just historically that they were initially put in Misc.java. Also I think it would be useful to do the change to the Unix implementation separately, I think that needs a summary in the first place to understand why that change is needed. |
The issue was filed against the Unix implementation, so if the Unix implementation is separated from Windows then I think the Windows content should be moved to a new PR. |
See JDK-8315241. |
I can add a comment in the source, but here's some illustrative behavior using and attempts to convert master As can be seen, when attempting to resolve the path without following links, the result is a non-existent file. patch Here the correct result is obtained. |
AlanBateman
left a comment
There was a problem hiding this comment.
I think looks okay, and I assume the work on converting the test to a standalone JUnit test will expand the test coverage to include this scenario.
|
@bplb This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be: You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 1 new commit pushed to the
Please see this link for an up-to-date comparison between the source branch of this pull request and the ➡️ To integrate this PR with the above commit message to the |
It will, and the test will initially have to be excluded on Windows until JDK-8315273 is fixed. |
|
/integrate |
|
Going to push as commit 63f561f.
Your commit was automatically rebased without conflicts. |
Modify
Path.toRealPathsuch that it does not collapse links such as "link/.." or "link/../.." whenLinkOption.NOFOLLOW_LINKSis specified or, in some cases, not.Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/15397/head:pull/15397$ git checkout pull/15397Update a local copy of the PR:
$ git checkout pull/15397$ git pull https://git.openjdk.org/jdk.git pull/15397/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 15397View PR using the GUI difftool:
$ git pr show -t 15397Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/15397.diff
Webrev
Link to Webrev Comment