ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 15465] New: - org.apache.tools.bzip2.CBZip2InputStream dies in constructor
Date Tue, 17 Dec 2002 23:12:46 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15465>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15465

org.apache.tools.bzip2.CBZip2InputStream dies in constructor

           Summary: org.apache.tools.bzip2.CBZip2InputStream dies in
                    constructor
           Product: Ant
           Version: 1.5.1
          Platform: All
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Core
        AssignedTo: ant-dev@jakarta.apache.org
        ReportedBy: macherius@infonyte.com
                CC: keiron@aftexsw.com,macherius@infonyte.com


Summary:
org.apache.tools.bzip2.CBZip2InputStream dies in constructor

Effect:
Exception in thread "main" java.lang.NullPointerException
at org.apache.tools.bzip2.CBZip2InputStream.bsR(CBZip2InputStream.java:327)
at org.apache.tools.bzip2.CBZip2InputStream.bsGetUChar(CBZip2InputStream.java:346)
at org.apache.tools.bzip2.CBZip2InputStream.initBlock(CBZip2InputStream.java:232)
at org.apache.tools.bzip2.CBZip2InputStream.<init>(CBZip2InputStream.java:180)
at tgz.main(tgz.java:21)

Reproduce:
1) Take any file and compressed it with a current bzip2
e.g. "bzip2, a block-sorting file compressor.  Version 1.0.2, 30-Dec-2001."
2) Try to open a CBZip2InputStream from that file as follows

...
File f = new File(freeb_win_tar_bz2);
FileInputStream fis = new FileInputStream(f);
System.out.println(fis);
// This object is fine, gives e.g. java.io.FileInputStream@1ea2dfe
CBZip2InputStream cbz2is = new CBZip2InputStream(fis);
// -> NPE
...

3) See it dying.

Fix:
Very simple. The issue is in the "initialize()" method of CBZip2InputStream.java
(line 215 ff). It just does not skip the initial "BZ" constant chars as follows:

----- old version follows (as in Apache CVS by today)
    private void initialize() {
        char magic3, magic4;
        magic3 = bsGetUChar();
        magic4 = bsGetUChar();
        if (magic3 != 'h' || magic4 < '1' || magic4 > '9') {
...
----- new follows
    private void initialize() {
        char magic1, magic2;
        char magic3, magic4;
        magic1 = bsGetUChar();
        magic2 = bsGetUChar();
        magic3 = bsGetUChar();
        magic4 = bsGetUChar();
        if (magic1 != 'B' || magic2 != 'Z' | magic3 != 'h' || magic4 < '1' ||
magic4 > '9') {
...

Is it considered that the user application skips the first two bytes of an
InputStream ? If so, it should be documented somewhere. If not, the above fix
should be put into the CVS.

Thanks for your attention !
Ingo Macherius <macherius at infonyte dot com>

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message