commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stefan Bodewig (JIRA)" <>
Subject [jira] [Commented] (COMPRESS-174) BZip2CompressorInputStream doesn't handle being given a wrong-format compressed file
Date Fri, 18 Apr 2014 13:27:15 GMT


Stefan Bodewig commented on COMPRESS-174:

Hmm, the original report was about trying to read from a stream that's not in fact a bzip2
stream - are you talking about the same thing Daniel?

By now the init method called by the constructor should fail with an IOException when handed
such a stream.  I'll write a unit test for feeding a zip file to BZip2InputStream.

> BZip2CompressorInputStream doesn't handle being given a wrong-format compressed file
> ------------------------------------------------------------------------------------
>                 Key: COMPRESS-174
>                 URL:
>             Project: Commons Compress
>          Issue Type: Bug
>          Components: Compressors
>    Affects Versions: 1.3
>         Environment: Linux and Windows
>            Reporter: Andrew Pavlin
>            Priority: Minor
>             Fix For: 1.9
> When reading a file through BZip2CompressorInputStream, and the user selects a file of
the wrong type (such as ZIP or GZIP), the read blows up with a strange ArrayIndexOutOfBoundException,
instead of reporting immediately that the input data is of the wrong format.
> The Bzip2Compressor should be able to identify whether a stream is of BZip2 format or
not, and immediately reject it with a meaningful exception (example: "ProtocolException: not
a BZip2 compressed file").
> Alternatively, are there functions in commons-compress that can identify the compression
type of an InputStream by inspection?
> Example stack trace when using a ZIP input file:
> Exception in thread "OSM Decompressor" java.lang.ArrayIndexOutOfBoundsException: 900000

>         at org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream.getAndMoveToFrontDecode(

>         at org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream.initBlock(

>         at org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream.setupNoRandPartA(

>         at org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream.setupNoRandPartB(

>         at org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream.read0(

>         at

>         at 
>         at org.ka2ddo.yaac.osm.OsmXmlSegmenter$ 
>         at 

This message was sent by Atlassian JIRA

View raw message