[jira] [Commented] (COMPRESS-529) Tar decompression fails with runtime exceptions
[ https://issues.apache.org/jira/browse/COMPRESS-529?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17120889#comment-17120889 ] Peter Lee commented on COMPRESS-529: And fixed with commit 36773d948e9a220c1dc3abec3d2028b0879a7766 > 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 >Assignee: Peter Lee >Priority: Major > 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)
[jira] [Commented] (COMPRESS-529) Tar decompression fails with runtime exceptions
[ https://issues.apache.org/jira/browse/COMPRESS-529?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17120506#comment-17120506 ] Stefan Bodewig commented on COMPRESS-529: - At least the two of us share the same misunderstanding, then :) If anything is wrong with a stream we read, we should always try to turn this into an {{IOException}}. This is something we don't always do, obviously, as [~zuevmaxim] 's issues show. When writing things are a bit different as we can expect the user to only hand us valid inputs IMHO. The second issue here must expect errors as this is what {{TarArchiveOutputStream}} does for file names that are too long or numbers that are too big unless you tell it otherwise - and this is documented. I agree we should turn the exceptions into {{IllegalArgumentException}}s - and document them at the public APIs that may throw them. Any client code that catches {{RuntimeException}}s now will automatically catch {{IllegalArgumentException}} as well, so we are on the safe side. > 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 > 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)
[jira] [Commented] (COMPRESS-529) Tar decompression fails with runtime exceptions
[ https://issues.apache.org/jira/browse/COMPRESS-529?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17119434#comment-17119434 ] Peter Lee commented on COMPRESS-529: I see. The declared IOException is indeed a better exception than undeclared NumberFormatException. For the first issue, we could catch the NumberFormatException in TarArchiveInputStream.paxHeaders and rethrow an IOException. For the second issue, we could use {{IllegalArgumentException}} instead of RuntimeException, and we need more documentation to address this. Hope I'm not misunderstanding. > 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 > 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)
[jira] [Commented] (COMPRESS-529) Tar decompression fails with runtime exceptions
[ https://issues.apache.org/jira/browse/COMPRESS-529?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17119333#comment-17119333 ] Stefan Bodewig commented on COMPRESS-529: - The point of this bug report is that it happens when you read an archive. The exception occurs in {{getNextEntry}} . Here the user expects an {{IOException}} and probably catches it, but will not catch a {{NumberFormatException}}. So while wrapping the NFE into an IOE may not provide useful information, it will make the user code hande the exception and use a controlled path of exception. This is a benefit in itself. > 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 > 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)
[jira] [Commented] (COMPRESS-529) Tar decompression fails with runtime exceptions
[ https://issues.apache.org/jira/browse/COMPRESS-529?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17118656#comment-17118656 ] Peter Lee commented on COMPRESS-529: For the first issue : {code:java} Exception in thread "main" java.lang.NumberFormatException: For input string: "143266�921.098285006" at java.base/jdk.internal.math.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2054) {code} Seems we could catch this exception in TarArchiveInputStream.paxHeaders and rethrow the IOException - this could throw the IOException without breaking the binary compatibility. But it seems we could not provide enough information if we want to rethrow IOException here - we do not know which is the key with a corrupted value. In that way the IOException would do no good here - users are still confused. I don't like this solution. Any better ideas? [~zuevmaxim] [~bodewig] > 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 > 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)
[jira] [Commented] (COMPRESS-529) Tar decompression fails with runtime exceptions
[ https://issues.apache.org/jira/browse/COMPRESS-529?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17116739#comment-17116739 ] Peter Lee commented on COMPRESS-529: > _In this particular case I disagree. I think an {{IllegalArgumentException}} >is fine if you invoke one of the {{putArchiveEntry}} variants. We might need >to add more documentation, granted, but this is not an I/O error of any kind >and the caller is in full control of what it passes in as argument._ +1. I can't see any help if we change from RuntimeException to IOException - users will still be confused if they do not know there's such a thing like long file mode. More documentation is what we need here. And the NumberFormatException.tar problem is fixed in commit b8a0b54c59191cb8338585eab055897737730a9e. > 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 > Attachments: LongName.tar, NumberFormatException.tar > > > 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)
[jira] [Commented] (COMPRESS-529) Tar decompression fails with runtime exceptions
[ https://issues.apache.org/jira/browse/COMPRESS-529?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17116590#comment-17116590 ] Stefan Bodewig commented on COMPRESS-529: - {{LONGFILE_ERROR}} is the default, we may need to document more properly what kind of error will be thrown. > 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 > Attachments: LongName.tar, NumberFormatException.tar > > > 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)
[jira] [Commented] (COMPRESS-529) Tar decompression fails with runtime exceptions
[ https://issues.apache.org/jira/browse/COMPRESS-529?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17116586#comment-17116586 ] Stefan Bodewig commented on COMPRESS-529: - In this particular case I disagree. I think an {{IllegalArgumentException}} is fine if you invoke one of the {{putArchiveEntry}} variants. We might need to add more documentation, granted, but this is not an I/O error of any kind and the caller is in full control of what it passes in as argument. > 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 > Attachments: LongName.tar, NumberFormatException.tar > > > 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)
[jira] [Commented] (COMPRESS-529) Tar decompression fails with runtime exceptions
[ https://issues.apache.org/jira/browse/COMPRESS-529?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17116574#comment-17116574 ] Maksim Zuev commented on COMPRESS-529: -- ??Or maybe you are just talking that we should throw IOException instead of RuntimeException??? Yes, I meant exactly that. > 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 > Attachments: LongName.tar, NumberFormatException.tar > > > 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)
[jira] [Commented] (COMPRESS-529) Tar decompression fails with runtime exceptions
[ https://issues.apache.org/jira/browse/COMPRESS-529?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17116544#comment-17116544 ] Peter Lee commented on COMPRESS-529: Disclaimer : I'm not that familiar with kotlin so feel free to tell if I make any mistakes. :) For the second issue(a.k.a the LongName.tar issue) : If I understand this issue correctly, you're creating a tar entry with a name which is longer than 100 byte. Then you got an Runtime Exception which is telling you that the file name is too long. Isn't it? Actually this is expected exception cause you didn't set the longFileMode for aos and it's set as default value : LONGFILE_ERROR, which means we will throw an exception if the file name is too long. Just try something like {code:java} aos.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU); {code} and you would not get this exception any more. Or maybe you are just talking that we should throw IOException instead of RuntimeException? > 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 > Attachments: LongName.tar, NumberFormatException.tar > > > 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)