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

jar xf does not work on zip files with leading garbage

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 9
    • None
    • core-libs
    • b33
    • generic
    • generic
    • Verified

        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!).

              martin Martin Buchholz
              martin Martin Buchholz
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: