You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Stefan Bodewig (Jira)" <ji...@apache.org> on 2020/06/01 11:18:02 UTC

[jira] [Resolved] (COMPRESS-529) Tar decompression fails with runtime exceptions

     [ https://issues.apache.org/jira/browse/COMPRESS-529?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Stefan Bodewig resolved COMPRESS-529.
-------------------------------------
    Fix Version/s: 1.21
         Assignee:     (was: Peter Lee)
       Resolution: Fixed

> Tar decompression fails with runtime exceptions
> -----------------------------------------------
>
>                 Key: COMPRESS-529
>                 URL: https://issues.apache.org/jira/browse/COMPRESS-529
>             Project: Commons Compress
>          Issue Type: Bug
>    Affects Versions: 1.20
>            Reporter: Maksim Zuev
>            Priority: Major
>             Fix For: 1.21
>
>         Attachments: LongName.tar, NumberFormatException.tar, japicmp.html, japicmp.html
>
>
> This Kotlin code fails with exception(NumberFormatException.tar is in the attachment)
> Exception in thread "main" java.lang.NumberFormatException: For input string: "143266�921.098285006"
>  at java.base/jdk.internal.math.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2054)
>  at java.base/jdk.internal.math.FloatingDecimal.parseDouble(FloatingDecimal.java:110)
>  at java.base/java.lang.Double.parseDouble(Double.java:543)
>  at org.apache.commons.compress.archivers.tar.TarArchiveEntry.processPaxHeader(TarArchiveEntry.java:1161)
>  at org.apache.commons.compress.archivers.tar.TarArchiveEntry.updateEntryFromPaxHeaders(TarArchiveEntry.java:1093)
>  at org.apache.commons.compress.archivers.tar.TarArchiveInputStream.applyPaxHeadersToCurrentEntry(TarArchiveInputStream.java:757)
>  at org.apache.commons.compress.archivers.tar.TarArchiveInputStream.paxHeaders(TarArchiveInputStream.java:562)
>  at org.apache.commons.compress.archivers.tar.TarArchiveInputStream.getNextTarEntry(TarArchiveInputStream.java:404)
>  at org.apache.commons.compress.archivers.tar.TarArchiveInputStream.getNextEntry(TarArchiveInputStream.java:799)
>  at ru.example.kotlinfuzzer.tests.MainKt.main(main.kt:69)
>  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("NumberFormatException.tar")
>     ArchiveStreamFactory().createArchiveInputStream("tar", tar.inputStream()).use { ais ->
>         ais.nextEntry
>         ais.readAllBytes()
>     }
> }
> {code}
> This Kotlin code fails with exception(LongName.tar is in the attachment)
> Exception in thread "main" java.lang.RuntimeException: file name 'asidhuasih a
>  sdjn osdn 
>  sdvs ndv
>  asdjbhasdb asb iasbfi basdigf basduio 
>  asdkhasjdhasd
>  asdjkhasnjddjasjdas
>  /?' is too long ( > 100 bytes)
>  at org.apache.commons.compress.archivers.tar.TarArchiveOutputStream.handleLongName(TarArchiveOutputStream.java:683)
>  at org.apache.commons.compress.archivers.tar.TarArchiveOutputStream.putArchiveEntry(TarArchiveOutputStream.java:358)
>  at ru.example.kotlinfuzzer.tests.MainKt.test(main.kt:20)
>  at ru.example.kotlinfuzzer.tests.MainKt.main(main.kt:8)
>  at ru.example.kotlinfuzzer.tests.MainKt.main(main.kt)
> {code:java}
> import org.apache.commons.compress.archivers.ArchiveStreamFactory
> import org.apache.commons.compress.archivers.tar.TarArchiveEntry
> import java.io.File
> fun main() {
>     test(File("LongName.tar"))
> }
> fun test(tar: File) {
>     val (decompressed, name) = ArchiveStreamFactory().createArchiveInputStream("tar", tar.inputStream()).use { ais ->
>         val entry = ais.nextEntry
>         ais.readAllBytes() to entry.name
>     }
>     File.createTempFile("apache_", ".tar").also {
>         ArchiveStreamFactory().createArchiveOutputStream("tar", it.outputStream()).use { aos ->
>             val entry = TarArchiveEntry(name)
>             entry.size = decompressed.size.toLong()
>             aos.putArchiveEntry(entry)
>             try {
>                 aos.write(decompressed)
>             } finally {
>                 aos.closeArchiveEntry()
>             }
>         }
>     }
> }
> {code}
>  
> IOException expected



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