harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stepan Mishura" <stepan.mish...@gmail.com>
Subject Re: [classlib][security] HARMONY-5054 status was ([jira] Created: (HARMONY-5054) [ASN.1] BerInputStream will incorrectly resize buffer when the enveloped InputStream has lots of bytes)
Date Wed, 14 Nov 2007 12:12:14 GMT
On 11/14/07, Spark Shen <smallsmallorgan@gmail.com> wrote:
<SNIP>
>
> I checked your fix, and seems my second point did not convinced you. :-)

Quite opposite :-)

I think the issues you reported are different so I'm going to do separate fixes.

> 2. In method readContent, the if statement:
>
>            if (in.read(buffer, offset, length) != length) {
>                throw new ASN1Exception(Messages.getString("security.13C"));
> //$NON-NLS-1$
>            }
>            offset += length;
> is not enough to guarantee all the bytes are read into buffer. This can be
> fixed using a while loop:
>
>            int numread = 0, oldoffset = offset;
>            while ((numread = in.read(buffer, offset, length)) > 0) {
>                offset += numread;
>                length -= numread;
>                if(length == 0) {
>                    break;
>                }
>            }
>            length = offset - oldoffset;
> When decoding input from an inputStream retrieved from socket, the if
> statement here is not adequate
> to guarantee all the response bytes from server been collected.
>
> I doubt the off-line reproducer can unveal this bug. Correct if I am wrong.
>

I got the idea and going to try to create off-line reproducer by
implementing custom InputStream.

Thanks,
Stepan.

<SNIP>

Mime
View raw message