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

jar can add files to an archive that it can't later extract

    Details

    • Subcomponent:
    • Resolved In Build:
      b01
    • CPU:
      generic
    • OS:
      solaris

      Description

      The java 1.4 version of the jar command (both 32-bit and 64-bit) can not extract files that are larger than 2^31-1 (2147483647). However, it can add files that are larger than this. The result is that you can have an archive with files in it that can not be extracted without getting a ZipException like this:

      java.util.zip.ZipException: invalid entry size (expected 2920611840 but got -1374355456 bytes)

      This is a classic signed int overflow situation -- -1374355456 == unsigned 2920611840

      java 1.5 and later does not have this problem

      Here is a test case

      + /usr/sbin/mkfile -n 2147483648 2147483648
      + /usr/j2se/bin/java -version
      java version "1.4.2_06"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_06-b03)
      Java HotSpot(TM) Client VM (build 1.4.2_06-b03, mixed mode)
      + /usr/j2se/bin/jar cvf test.jar 2147483648
      added manifest
      adding: 2147483648(in = -2147483648) (out= 2087262)(deflated 100%)
      + /usr/j2se/bin/jar tvf test.jar
           0 Thu Apr 27 13:01:34 PDT 2006 META-INF/
          71 Thu Apr 27 13:01:34 PDT 2006 META-INF/MANIFEST.MF
      java.util.zip.ZipException: invalid entry size (expected 2147483648 but got -2147483648 bytes)
              at java.util.zip.ZipInputStream.readEnd(ZipInputStream.java:367)
              at java.util.zip.ZipInputStream.read(ZipInputStream.java:141)
              at java.util.zip.ZipInputStream.closeEntry(ZipInputStream.java:91)
              at sun.tools.jar.Main.list(Main.java:744)
              at sun.tools.jar.Main.run(Main.java:192)
              at sun.tools.jar.Main.main(Main.java:904)

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                kevinw Kevin Walls
                Reporter:
                duke J. Duke (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: