mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "vam" <...@nv.hanty.usi.ru>
Subject RE: ObjectSerialization problem
Date Tue, 12 Dec 2006 06:24:05 GMT
Hi.


In
org.apache.mina.filter.codec.serialization.ObjectSerializationInputStream.ja
va there is bug.


public class ObjectSerializationInputStream extends InputStream implements
ObjectInput {

    ...

    public Object readObject() throws ClassNotFoundException, IOException
    {
        int objectSize = in.readInt();
        if( objectSize <= 0 )
        {
            throw new StreamCorruptedException( "Invalid objectSize: " +
objectSize );
        }
        if( objectSize > maxObjectSize )
        {
            throw new StreamCorruptedException(
                    "ObjectSize too big: " + objectSize +
                    " (expected: <= " + maxObjectSize + ')' );
        }
        
        ByteBuffer buf = ByteBuffer.allocate( objectSize + 4, false );
        buf.putInt( objectSize );
        in.readFully( buf.array(), 4, objectSize );
        buf.position( 0 );

        // !!! Replace this please
        // buf.limit( objectSize );
        //
----------------------------------------------------------------------------
-------------------
        buf.limit( objectSize + 4 );
        
        Object answer = buf.getObject( classLoader );
        buf.release();
        return answer;
    }
    
    ...

}

Sorry, my poor English...
Andrew Vokhmin.



Mime
View raw message