[jira] [Commented] (COMPRESS-545) Decompression fails with ArrayIndexOutOfBoundsException

2021-03-06 Thread Stefan Bodewig (Jira)


[ 
https://issues.apache.org/jira/browse/COMPRESS-545?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17296641#comment-17296641
 ] 

Stefan Bodewig commented on COMPRESS-545:
-

I just confirmed both archives lead to IOExceptions by now.

> Decompression fails with ArrayIndexOutOfBoundsException
> ---
>
> Key: COMPRESS-545
> URL: https://issues.apache.org/jira/browse/COMPRESS-545
> Project: Commons Compress
>  Issue Type: Bug
>Affects Versions: 1.20
>Reporter: Maksim Zuev
>Priority: Major
> Fix For: 1.21
>
> Attachments: ArrayIndexOutOfBoundsException1.zip, 
> ArrayIndexOutOfBoundsException2.zip
>
>
> This Kotlin code fails with exception(ArrayIndexOutOfBoundsException1.zip is 
> in the attachments)
> Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 30 
> out of bounds for length 29Exception in thread "main" 
> java.lang.ArrayIndexOutOfBoundsException: Index 30 out of bounds for length 
> 29 at 
> org.apache.commons.compress.compressors.deflate64.HuffmanDecoder$HuffmanCodes.decodeNext(HuffmanDecoder.java:321)
>  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 
> kotlinx.fuzzer.tests.apache.zip.ApacheZipTestKt.main(ApacheZipTest.kt:86) at 
> kotlinx.fuzzer.tests.apache.zip.ApacheZipTestKt.main(ApacheZipTest.kt)
> {code:java}
> import org.apache.commons.compress.archivers.ArchiveStreamFactory
> import java.io.ByteArrayInputStream
> import java.io.File
> fun main() {
> val bytes = File("ArrayIndexOutOfBoundsException1.zip").readBytes()
> val input = ByteArrayInputStream(bytes)
> ArchiveStreamFactory().createArchiveInputStream("zip", input).use { ais ->
> ais.nextEntry
> ais.readAllBytes()
> }
> }
> {code}
> Expected some other exception as IOException is the only declared.
>  
> This Kotlin code fails with exception(ArrayIndexOutOfBoundsException2.zip is 
> in the attachments)
> Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index -1 
> out of bounds for length 8192Exception in thread "main" 
> java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 
> 8192 at 
> org.apache.commons.compress.compressors.lzw.LZWInputStream.expandCodeToOutputStack(LZWInputStream.java:232)
>  at 
> org.apache.commons.compress.archivers.zip.UnshrinkingInputStream.decompressNextSymbol(UnshrinkingInputStream.java:124)
>  at 
> org.apache.commons.compress.compressors.lzw.LZWInputStream.read(LZWInputStream.java:80)
>  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 
> kotlinx.fuzzer.tests.apache.zip.ApacheZipTestKt.main(ApacheZipTest.kt:86) at 
> kotlinx.fuzzer.tests.apache.zip.ApacheZipTestKt.main(ApacheZipTest.kt)
> {code:java}
> import org.apache.commons.compress.archivers.ArchiveStreamFactory
> import java.io.ByteArrayInputStream
> import java.io.File
> fun main() {
> val bytes = File("ArrayIndexOutOfBoundsException2.zip").readBytes()
> val input = ByteArrayInputStream(bytes)
> ArchiveStreamFactory().createArchiveInputStream("zip", input).use { ais ->
> ais.nextEntry
> ais.readAllBytes()
> }
> }
> {code}
> Expected some other exception as IOException is the only declared.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (COMPRESS-545) Decompression fails with ArrayIndexOutOfBoundsException

2020-09-02 Thread Peter Lee (Jira)


[ 
https://issues.apache.org/jira/browse/COMPRESS-545?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17189231#comment-17189231
 ] 

Peter Lee commented on COMPRESS-545:


For ArrayIndexOutOfBoundsException1.zip, the Runtime Exception has already been 
wrapped with a IOException :
{code:java}
java.io.IOException:
Invalid Deflate64 input



at
org.apache.commons.compress.compressors.deflate64.Deflate64CompressorInputStream.read(Deflate64CompressorInputStream.java:87)
at
org.apache.commons.compress.archivers.zip.ZipArchiveInputStream.read(ZipArchiveInputStream.java:506)
at
org.apache.commons.compress.archivers.zip.ZipArchiveInputStream.skip(ZipArchiveInputStream.java:668)
at
org.apache.commons.compress.archivers.zip.ZipArchiveInputStream.closeEntry(ZipArchiveInputStream.java:739)
at
org.apache.commons.compress.archivers.zip.ZipArchiveInputStream.getNextZipEntry(ZipArchiveInputStream.java:260)
at
org.apache.commons.compress.archivers.zip.ZipArchiveInputStream.getNextEntry(ZipArchiveInputStream.java:448)
at
org.apache.commons.compress.archivers.zip.ZipArchiveInputStreamTest.test545(ZipArchiveInputStreamTest.java:736)
at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at
java.lang.reflect.Method.invoke(Method.java:498)
at
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
at
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at
org.junit.rules.ExpectedException$ExpectedExceptionStatement.evaluate(ExpectedException.java:258)
at
org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at
org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
at
org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
at
org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
at
org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
at
org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
at
org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
at
org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
at
org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at
org.junit.runners.ParentRunner.run(ParentRunner.java:413)
at
org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at
com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at
com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
at
com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230)
at
com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58)
Caused
by: java.lang.ArrayIndexOutOfBoundsException: 30
at
org.apache.commons.compress.compressors.deflate64.HuffmanDecoder$HuffmanCodes.decodeNext(HuffmanDecoder.java:321)
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:85)
...
32 more
{code}
For ArrayIndexOutOfBoundsException2.zip, I think it's already fixed by other 
commits : a EOFException is thrown now.

> Decompression fails with ArrayIndexOutOfBoundsException
> ---
>
> Key: COMPRESS-545
> URL: https://issues.apache.org/jira/browse/COMPRESS-545
> Project: Commons Compress
>  Issue Type: Bug
>Affects Versions: 1.20
>Reporter: Maksim Zuev
>Priority: Major
> Attachments: ArrayIndexOutOfBoundsException1.zip, 
> ArrayIndexOutOfBoundsException2.zip
>
>
> This Kotlin code fails with exception(ArrayIndexOutOfBoundsException1.zip is 
> in the attachments)
> Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 30 
> out of bounds for length 29Exception in thread "main" 
> java.lang.ArrayIndexOutOfBoundsException: Index 30 out of bounds for length 
> 29 at 
>