[
https://issues.apache.org/jira/browse/COMPRESS-528?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17127292#comment-17127292
]
Peter Lee commented on COMPRESS-528:
The name in the InconsistentSize.tar is null and the type of the tar is POSIX,
so we are concating the prefix with the filename. For the prefix, it's also
null and parsed as 000(in UTF-8), so the actual name for the entry turns out to
be "000/" : "000"(prefix) + "/" + null(name). Therefore we are regarding this
entry as a directory(cause the name is ended with '/'), and we will return -1
when reading from it(not sure how you are getting 0 in Kotlin, I'm debugging
with Java).
I changed the name while debuging and is getting an IOException cause the
InconsistentSize.tar do not have any actual data - I believe this tarball is a
man-made tarball and it's not a normal tarball.
Anyway, I agree with [~bodewig] : to throw an Exception or not throwing one
would all make sense here. But changing it may break the compatibility and
would cause more problems.
> Tar decompression - Inconsistent entry size
> ---
>
> Key: COMPRESS-528
> URL: https://issues.apache.org/jira/browse/COMPRESS-528
> Project: Commons Compress
> Issue Type: Bug
>Affects Versions: 1.20
>Reporter: Maksim Zuev
>Priority: Major
> Attachments: InconsistentSize.tar
>
>
> Expected that
> {{[getSize|https://commons.apache.org/proper/commons-compress/javadocs/api-1.20/org/apache/commons/compress/archivers/tar/TarArchiveEntry.html#getSize--]()
> }}returns the size of byte array read from ArchiveInputStream
> To reproduce run this Kotlin code(InconsistentSize.tar is in the attachment).
> It fails with exception
> Exception in thread "main" java.lang.IllegalStateException: 19 expected but 0
> found
> at ru.example.kotlinfuzzer.tests.MainKt.main(main.kt:82)
> at ru.example.kotlinfuzzer.tests.MainKt.main(main.kt)
> {code:java}
> import org.apache.commons.compress.archivers.ArchiveStreamFactory
> import java.io.File
> fun main() {
> val tar = File("InconsistentSize.tar")
> ArchiveStreamFactory().createArchiveInputStream("tar",
> tar.inputStream()).use { ais ->
> val expected = ais.nextEntry.size
> val actual = ais.readAllBytes().size.toLong()
> check(expected == actual) { "$expected expected but $actual found" }
> }
> }
> {code}
> {{}}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)