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

jar xf does not work on zip files with leading garbage

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 9
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b33
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Verified

      Backports

        Description

        If you have a jar file with prepended garbage, such as a shell script or ELF file, which is a common practice, then we expect that common commands like "jar" that simply read the file will continue to work.

        In fact,
        jar tf
        always works, but
        jar xf only works if some files are specified to extract, and this difference appears to have no reason.

        Although there may be performance reasons to use ZipInputStream to ZipFile, if ZipInputStream can find no entries, and the input file is seekable, "jar" should fall back to using ZipFile.

        There's a curious hacky workaround for the desparate:
        jar xf foo.zip ''
        will have the same effect as
        jar xf foo.zip
        but will additionally work on zip files with prepended garbage (but this relies on implementation details - uses String.startsWith!).

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                martin Martin Buchholz
                Reporter:
                martin Martin Buchholz
                Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: