Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8274727

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

    XMLWordPrintable

Details

    • CSR
    • Resolution: Approved
    • P4
    • 11-pool
    • core-libs
    • None
    • behavioral
    • low
    • Hide
      While a Zip File could be opened with Zip FS prior to this change with entry names containing "." or "..", users would encounter errors accessing/updating these entries as all other access paths, with the exception of creating the Inode entries in ZipFileSystem::initCEN(), would invoke ZipPath::getResolvedPath prior to looking up the entry in the inode table.

      Entries such as this should be extremely rare(indicated by the fact we have not had any reports of problems updating these entries since JDK 8 with Zip FS).
      Show
      While a Zip File could be opened with Zip FS prior to this change with entry names containing "." or "..", users would encounter errors accessing/updating these entries as all other access paths, with the exception of creating the Inode entries in ZipFileSystem::initCEN(), would invoke ZipPath::getResolvedPath prior to looking up the entry in the inode table. Entries such as this should be extremely rare(indicated by the fact we have not had any reports of problems updating these entries since JDK 8 with Zip FS).
    • Other
    • JDK

    Description

      The CSR for JDK-8251329 , is the same as the original CSR (https://bugs.openjdk.java.net/browse/JDK-8271294) for release 11u.

      Summary

      A zip or JAR file containing "." or ".." entries cannot be reliably used as a file system. Change the zip file system provider to reject attempts to open an existing zip or JAR file that contains these entries. An attempt to open a zip file as a file system with the java.nio.file.FileSystems API may therefore fail with an exception, a behavior change from existing releases.

      Problem

      As Zip FS is a virtual file system, it needs to use "." and ".." as links to the current and parent directories. Because of this, Zip FS cannot reliably support entries that have "." and ".." as name elements.

      Having Zip entries such as "../Hello.txt" or "foo/./bar", ".", or ".." introduce inconsistencies for Zip FS. One such example is the use of Files::walk or Files::walkFileTree which will continue until memory is exhausted.

      Solution

      When opening a Zip File and encountering a Zip Entry containing an "." or ".." name element, a Zip Exception will be thrown with the message:

      "ZIP file can't be opened as a file system because an entry has a '.' or '..' element in its name"

      Specification

      We will update the follow section of the Zip FS module info:

      Accessing a Zip File System

      The FileSystems newFileSystem static factory methods can be used to:

      • Create a Zip file system
      • Open an existing file as a Zip file system

      Note: The Zip File System will throw a ZipException when opening an existing Zip file that contains Zip entries with "." or ".." in its name elements.

      Attachments

        Issue Links

          Activity

            People

              rreddy Ravi Reddy
              webbuggrp Webbug Group
              Lance Andersen
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: