Maksim Zuev created COMPRESS-521:
------------------------------------
Summary: Decompression fails with IllegalStateException
Key: COMPRESS-521
URL: https://issues.apache.org/jira/browse/COMPRESS-521
Project: Commons Compress
Issue Type: Bug
Affects Versions: 1.20
Reporter: Maksim Zuev
This Kotlin code fails with exception
Exception in thread "main" java.lang.IllegalStateException: Attempt to read
beyond memory: dist=9321
at
org.apache.commons.compress.compressors.deflate64.HuffmanDecoder$DecodingMemory.recordToBuffer(HuffmanDecoder.java:526)
at
org.apache.commons.compress.compressors.deflate64.HuffmanDecoder$HuffmanCodes.decodeNext(HuffmanDecoder.java:338)
at
org.apache.commons.compress.compressors.deflate64.HuffmanDecoder$HuffmanCodes.read(HuffmanDecoder.java:307)
at
org.apache.commons.compress.compressors.deflate64.HuffmanDecoder.decode(HuffmanDecoder.java:152)
at
org.apache.commons.compress.compressors.deflate64.Deflate64CompressorInputStream.read(Deflate64CompressorInputStream.java:84)
at
org.apache.commons.compress.archivers.zip.ZipArchiveInputStream.read(ZipArchiveInputStream.java:493)
at java.base/java.io.InputStream.readNBytes(InputStream.java:396)
at java.base/java.io.InputStream.readAllBytes(InputStream.java:333)
at ru.example.kotlinfuzzer.tests.CompressTestKt.main(CompressTest.kt:76)
at ru.example.kotlinfuzzer.tests.CompressTestKt.main(CompressTest.kt)
{code:java}
import org.apache.commons.compress.archivers.ArchiveStreamFactory
import java.io.ByteArrayInputStream
fun main() {
val bytes = listOf(
0x50, 0x4b, 0x03, 0x04, 0x2e, 0x00, 0xb6, 0x00, 0x09, 0x00,
0x84, 0xb6, 0xba, 0x46, 0x72, 0x00, 0xfe, 0x77, 0x63, 0x00,
0x00, 0x00, 0x6b, 0x00, 0x00, 0x00, 0x03, 0x00, 0x1c, 0x00,
0x62, 0x62, 0x62, 0x55, 0x54, 0x0c, 0x00, 0x03, 0xe7, 0xce,
0x64, 0x55, 0xf3, 0xce, 0x65, 0x55, 0x75, 0x78, 0x0b, 0x00,
0x01, 0x04, 0x5c, 0xf9, 0x01, 0x00, 0x04, 0x88, 0x13, 0x00,
0x00, 0x42, 0x5a, 0x68, 0x34
).map { it.toByte() }.toByteArray()
val input = ByteArrayInputStream(bytes)
ArchiveStreamFactory().createArchiveInputStream("zip", input).use { ais ->
ais.nextEntry
ais.readAllBytes()
}
}
{code}
IOException expected
--
This message was sent by Atlassian Jira
(v8.3.4#803005)