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

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

    XMLWordPrintable

    Details

    • Type: CSR
    • Status: Closed
    • Priority: P4
    • Resolution: Approved
    • Fix Version/s: 17-pool
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Compatibility Kind:
      behavioral
    • Compatibility Risk:
      low
    • Compatibility Risk Description:
      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).
    • Interface Kind:
      Other
    • Scope:
      JDK

      Description

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

      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

              Assignee:
              rreddy Ravi Reddy
              Reporter:
              webbuggrp Webbug Group
              Reviewed By:
              Lance Andersen
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: