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

ZipArchiveInputStream#getNextZipEntry should verify compressed size is known for bzip2, implode etc.

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.15
    • Fix Version/s: 1.16
    • Component/s: Archivers
    • Labels:

      Description

              if (current.entry.getCompressedSize() != ArchiveEntry.SIZE_UNKNOWN) {
                  if (current.entry.getMethod() == ZipMethod.UNSHRINKING.getCode()) {
                      current.in = new UnshrinkingInputStream(new BoundedInputStream(in, current.entry.getCompressedSize()));
                  } else if (current.entry.getMethod() == ZipMethod.IMPLODING.getCode()) {
                      current.in = new ExplodingInputStream(
                              current.entry.getGeneralPurposeBit().getSlidingDictionarySize(),
                              current.entry.getGeneralPurposeBit().getNumberOfShannonFanoTrees(),
                              new BoundedInputStream(in, current.entry.getCompressedSize()));
                  } else if (current.entry.getMethod() == ZipMethod.BZIP2.getCode()) {
                      current.in = new BZip2CompressorInputStream(new BoundedInputStream(in, current.entry.getCompressedSize()));
                  }
              }
      

      never sets current.in if the compressed size is unknown which probably leads to a NullPointerException in read later. We should fail early with a useful error message instead.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              bodewig Stefan Bodewig
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: