RFR: 8251329: (zipfs) Files.walkFileTree walks infinitely if zip has dir named "." inside

Alan Bateman alanb at openjdk.java.net
Mon Jul 26 07:54:06 UTC 2021


On Sun, 25 Jul 2021 21:56:10 GMT, Lance Andersen <lancea at openjdk.org> wrote:

> Hi,
> 
> As discussed in the https://mail.openjdk.java.net/pipermail/core-libs-dev/2021-July/079621.html thread, this is the revised patch to address the use of '.' and '..' within Zip FS
> 
> Zip FS needs to use "." and ".." as links to the current and parent directories and cannot reliably support entries that have "." and ".." as name elements.  This patch updates Zip Fs  to reject ZIP files that have entries in the CEN that can't be used for files in a file system.
> 
> 
> Mach5 tiers 1 through 3 have been run without any errors encountered .
> 
> Best,
> Lance

This is behavior change (to reject zip/JAR files) so a CSR will be required. I've also added a label to the JBS issue to remind us to add a release note.

I think it would be good for @jaikiran to review too.

src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java line 1573:

> 1571:             }
> 1572:             IndexNode inode = new IndexNode(cen, pos, nlen);
> 1573:             if(hasDotOrDotDot(inode.name)) {

Minor nit, missing space in "if(".

src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java line 1602:

> 1600:         // Inode.name always includes "/" in path[0]
> 1601:         if (path.length == 1) {
> 1602:             return false;

It may be useful to add "assert path[0] == '/';" at the start of this method.

test/jdk/jdk/nio/zipfs/HasDotDotTest.java line 1:

> 1: import org.testng.annotations.DataProvider;

Missing copyright header.

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

PR: https://git.openjdk.java.net/jdk/pull/4900


More information about the core-libs-dev mailing list