[
https://issues.apache.org/jira/browse/COMPRESS-436?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16312715#comment-16312715
]
Stefan Bodewig commented on COMPRESS-436:
-----------------------------------------
Most likely this is invalid. The compressed size should be known unless a data
descriptor is used, in which case {{read}} will throw the proper exception for
the methods we don't support data descriptors for. Most likely we've explicitly
decided to move all exceptions about unsupported constellations to {{read}} so
that you can skip over unreadable entries.
So I've changed the title and think it would be better to
* return {{false}} in {{canReadEntryData}} if the compressed size is unknown
for any of the methods that currently require it
* throw an exception in {{read}} in such a situation
> ZipArchiveInputStream#getNextZipEntry should verify compressed size is known
> for bzip2, implode etc.
> ----------------------------------------------------------------------------------------------------
>
> Key: COMPRESS-436
> URL: https://issues.apache.org/jira/browse/COMPRESS-436
> Project: Commons Compress
> Issue Type: Bug
> Components: Archivers
> Affects Versions: 1.15
> Reporter: Stefan Bodewig
> Labels: zip
> Fix For: 1.16
>
>
> {code}
> if (current.entry.getCompressedSize() != ArchiveEntry.SIZE_UNKNOWN) {
> if (current.entry.getMethod() == ZipMethod.UNSHRINKING.getCode())
> {
> current.in = new UnshrinkingInputStream(new
> BoundedInputStream(in, current.entry.getCompressedSize()));
> } else if (current.entry.getMethod() ==
> ZipMethod.IMPLODING.getCode()) {
> current.in = new ExplodingInputStream(
>
> current.entry.getGeneralPurposeBit().getSlidingDictionarySize(),
>
> current.entry.getGeneralPurposeBit().getNumberOfShannonFanoTrees(),
> new BoundedInputStream(in,
> current.entry.getCompressedSize()));
> } else if (current.entry.getMethod() ==
> ZipMethod.BZIP2.getCode()) {
> current.in = new BZip2CompressorInputStream(new
> BoundedInputStream(in, current.entry.getCompressedSize()));
> }
> }
> {code}
> never sets {{current.in}} if the compressed size is unknown which probably
> leads to a NullPointerException in {{read}} later. We should fail early with
> a useful error message instead.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)