Uploaded image for project: 'Commons Compress'
  1. Commons Compress
  2. COMPRESS-567

IllegalArgumentException in ZipFile.positionAtCentralDirectory

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.20
    • 1.21
    • None
    • None

    Description

      The following snippet of code throws an undeclared IllegalArgumentException:

      byte[] bytes = Base64.getDecoder().decode("UEsFBgAAAQD//////////1AAJP9QAA==");
      SeekableInMemoryByteChannel input = new SeekableInMemoryByteChannel(bytes);
      try {
          ZipFile file = new ZipFile(input);
      } catch (IOException ignored) {}
      

      The stack trace is:

      java.lang.IllegalArgumentException: Position has to be in range 0.. 2147483647
      	at org.apache.commons.compress.utils.SeekableInMemoryByteChannel.position(SeekableInMemoryByteChannel.java:94)
      	at org.apache.commons.compress.archivers.zip.ZipFile.positionAtCentralDirectory32(ZipFile.java:1128)
      	at org.apache.commons.compress.archivers.zip.ZipFile.positionAtCentralDirectory(ZipFile.java:1037)
      	at org.apache.commons.compress.archivers.zip.ZipFile.populateFromCentralDirectory(ZipFile.java:702)
      	at org.apache.commons.compress.archivers.zip.ZipFile.<init>(ZipFile.java:371)
      	at org.apache.commons.compress.archivers.zip.ZipFile.<init>(ZipFile.java:318)
      	at org.apache.commons.compress.archivers.zip.ZipFile.<init>(ZipFile.java:274)
      

      I also attached the input as a ZIP file.

      Attachments

        1. crash.zip
          0.0 kB
          Fabian Meumertzheim

        Activity

          People

            Unassigned Unassigned
            Meumertzheim Fabian Meumertzheim
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: