You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Andrew Pavlin (Created) (JIRA)" <ji...@apache.org> on 2012/02/01 05:08:58 UTC

[jira] [Created] (COMPRESS-174) BZip2CompressorInputStream doesn't handle being given a wrong-format compressed file

BZip2CompressorInputStream doesn't handle being given a wrong-format compressed file
------------------------------------------------------------------------------------

                 Key: COMPRESS-174
                 URL: https://issues.apache.org/jira/browse/COMPRESS-174
             Project: Commons Compress
          Issue Type: Bug
          Components: Compressors
    Affects Versions: 1.3
         Environment: Linux and Windows
            Reporter: Andrew Pavlin
            Priority: Minor


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(BZip2CompressorInputStream.java:688) 
        at org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream.initBlock(BZip2CompressorInputStream.java:322) 
        at org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream.setupNoRandPartA(BZip2CompressorInputStream.java:880) 
        at org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream.setupNoRandPartB(BZip2CompressorInputStream.java:936) 
        at org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream.read0(BZip2CompressorInputStream.java:228) 
        at org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream.read(BZip2CompressorInputStream.java:180) 
        at java.io.InputStream.read(InputStream.java:82) 
        at org.ka2ddo.yaac.osm.OsmXmlSegmenter$1.run(OsmXmlSegmenter.java:129) 
        at java.lang.Thread.run(Thread.java:680) 
 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (COMPRESS-174) BZip2CompressorInputStream doesn't handle being given a wrong-format compressed file

Posted by "Sebb (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COMPRESS-174?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13214199#comment-13214199 ] 

Sebb commented on COMPRESS-174:
-------------------------------

The method CompressorStreamFactory.createCompressorInputStream(InputStream) can be used to autodetect the compression type.
                
> BZip2CompressorInputStream doesn't handle being given a wrong-format compressed file
> ------------------------------------------------------------------------------------
>
>                 Key: COMPRESS-174
>                 URL: https://issues.apache.org/jira/browse/COMPRESS-174
>             Project: Commons Compress
>          Issue Type: Bug
>          Components: Compressors
>    Affects Versions: 1.3
>         Environment: Linux and Windows
>            Reporter: Andrew Pavlin
>            Priority: Minor
>
> 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(BZip2CompressorInputStream.java:688) 
>         at org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream.initBlock(BZip2CompressorInputStream.java:322) 
>         at org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream.setupNoRandPartA(BZip2CompressorInputStream.java:880) 
>         at org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream.setupNoRandPartB(BZip2CompressorInputStream.java:936) 
>         at org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream.read0(BZip2CompressorInputStream.java:228) 
>         at org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream.read(BZip2CompressorInputStream.java:180) 
>         at java.io.InputStream.read(InputStream.java:82) 
>         at org.ka2ddo.yaac.osm.OsmXmlSegmenter$1.run(OsmXmlSegmenter.java:129) 
>         at java.lang.Thread.run(Thread.java:680) 
>  

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Resolved] (COMPRESS-174) BZip2CompressorInputStream doesn't handle being given a wrong-format compressed file

Posted by "Jukka Zitting (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/COMPRESS-174?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jukka Zitting resolved COMPRESS-174.
------------------------------------

    Resolution: Not A Problem

Resolving as Not A Problem based on the existing CompressorStreamFactory functionality mentioned above by Sebb.
                
> BZip2CompressorInputStream doesn't handle being given a wrong-format compressed file
> ------------------------------------------------------------------------------------
>
>                 Key: COMPRESS-174
>                 URL: https://issues.apache.org/jira/browse/COMPRESS-174
>             Project: Commons Compress
>          Issue Type: Bug
>          Components: Compressors
>    Affects Versions: 1.3
>         Environment: Linux and Windows
>            Reporter: Andrew Pavlin
>            Priority: Minor
>
> 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(BZip2CompressorInputStream.java:688) 
>         at org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream.initBlock(BZip2CompressorInputStream.java:322) 
>         at org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream.setupNoRandPartA(BZip2CompressorInputStream.java:880) 
>         at org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream.setupNoRandPartB(BZip2CompressorInputStream.java:936) 
>         at org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream.read0(BZip2CompressorInputStream.java:228) 
>         at org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream.read(BZip2CompressorInputStream.java:180) 
>         at java.io.InputStream.read(InputStream.java:82) 
>         at org.ka2ddo.yaac.osm.OsmXmlSegmenter$1.run(OsmXmlSegmenter.java:129) 
>         at java.lang.Thread.run(Thread.java:680) 
>  

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira