commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stephan Schiessling...@rapi.com>
Subject [compress] Bug in TarInputStream
Date Mon, 31 Oct 2005 08:48:08 GMT

The

int read()

in TarInputStream

method should return values from 0..255
but indeed it returns values from -128..127.
To fix this, add 256, if value is negative.
Found this bug, because new GZIPInputStream(new TarInputStream(...))
will not recognize magic of GZIP.

Stephan

public int read()
        throws IOException
    {
        final int num = read( m_oneBuf, 0, 1 );
        if( num == -1 )
        {
            return num;
        }
        else
        {
            int b = (int)m_oneBuf[ 0 ];
            return b<0 ? b + 256 : b;
        }
    }

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message