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

Decompression fails with NegativeArraySizeException

    XMLWordPrintableJSON

Details

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

    Description

      This Kotlin code fails with exception(NegativeArraySizeException.zip is in the attachments)

      Exception in thread "main" java.lang.NegativeArraySizeException: -3

      at org.apache.commons.compress.archivers.zip.AsiExtraField.parseFromLocalFileData(AsiExtraField.java:271) at org.apache.commons.compress.archivers.zip.ExtraFieldUtils.fillExtraField(ExtraFieldUtils.java:324) at org.apache.commons.compress.archivers.zip.ZipArchiveEntry$ExtraFieldParsingMode.fillAndMakeUnrecognizedOnError(ZipArchiveEntry.java:1219) at org.apache.commons.compress.archivers.zip.ZipArchiveEntry$ExtraFieldParsingMode.access$100(ZipArchiveEntry.java:1127) at org.apache.commons.compress.archivers.zip.ZipArchiveEntry$ExtraFieldParsingMode$1.fill(ZipArchiveEntry.java:1142) at org.apache.commons.compress.archivers.zip.ExtraFieldUtils.parse(ExtraFieldUtils.java:214) at org.apache.commons.compress.archivers.zip.ZipArchiveEntry.setExtra(ZipArchiveEntry.java:675) at org.apache.commons.compress.archivers.zip.ZipArchiveInputStream.getNextZipEntry(ZipArchiveInputStream.java:341) at org.apache.commons.compress.archivers.zip.ZipArchiveInputStream.getNextEntry(ZipArchiveInputStream.java:435) at kotlinx.fuzzer.tests.apache.zip.ApacheZipTestKt.main(ApacheZipTest.kt:85) at kotlinx.fuzzer.tests.apache.zip.ApacheZipTestKt.main(ApacheZipTest.kt)

      import org.apache.commons.compress.archivers.ArchiveStreamFactory
      import java.io.ByteArrayInputStream
      import java.io.File
      
      fun main() {
          val bytes = File("NegativeArraySizeException.zip").readBytes()
          val input = ByteArrayInputStream(bytes)
          ArchiveStreamFactory().createArchiveInputStream("zip", input).use { ais ->
              ais.nextEntry
              ais.readAllBytes()
          }
      }
      

      Expected some other exception as IOException is the only declared.

      Attachments

        1. NegativeArraySizeException.zip
          0.1 kB
          Maksim Zuev

        Activity

          People

            peterlee Peter Lee
            zuevmaxim Maksim Zuev
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: