-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
8306882: (fs) Path.toRealPath(LinkOption.NOFOLLOW_LINKS) fails when "../../" follows a link #15397
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest to extract code for this case to a separate method. sun.nio.fs.WindowsLinkSupport#getRealPath
is already too big.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds like a good idea.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.toRealPath
such that it does not collapse links such as "link/.." or "link/../.." whenLinkOption.NOFOLLOW_LINKS
is specified or, in some cases, not.Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/15397/head:pull/15397
$ git checkout pull/15397
Update a local copy of the PR:
$ git checkout pull/15397
$ git pull https://git.openjdk.org/jdk.git pull/15397/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 15397
View PR using the GUI difftool:
$ git pr show -t 15397
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/15397.diff
Webrev
Link to Webrev Comment