harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Spark Shen" <smallsmallor...@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 Mon, 12 Nov 2007 06:42:33 GMT
2007/11/12, Spark Shen <smallsmallorgan@gmail.com>:
>
> Hi
>
> Stepan, Sorry for the so late reply. Regis, Liang Jia & I was busy
> developing ldap features and did not notice your comment. Please see my in
> line comments.
>
> <snip>
> But I can not understand what wrong with the BerInputStream constructor -
> in case of InputStream parameter the data is read from the beggining so
> offeset has to be 0.
> </snip>
> I think the problem is the next() method invocation on line 132 of
> constructor. In this method offset is updated. So when the program goes
> through line 137, the offset
> is no longer zero.
>
> <snip>
> A standalone test case would greatly help to understand what should be
> fixed.
> </snip>
> The test case requires a ldap server, and I planned to provide a scenario
> test and a adapter to BTI. But the effort was not trial as I expected.
>
> <snip>
> Could you provide first 10 bytes of incoming data and total size of ldap
> server request?
> </snip>
> Wait a minute please, I am working on it. :-)
> --
> Spark Shen
> China Software Development Lab, IBM


The following test case will reveal the problem:

package test;

import java.io.ByteArrayInputStream;
import org.apache.harmony.security.asn1.ASN1OctetString;

public class ASN1Test {

    public static void main(String[] args) {
        try {
            StringBuilder builder = new StringBuilder();
            for (int i = 0; i < 17000; i++) {
                builder.append("1");
            }
            ASN1OctetString octString = new ASN1OctetString();
            byte[] bytes = null;
            bytes = octString.encode(builder.toString().getBytes("UTF-8"));

            Object st;
            st = octString.decode(new ByteArrayInputStream(bytes));
            String string = new String((byte[]) st);
            System.out.println(string);
            return;
        } catch (Exception e1) {
            e1.printStackTrace();
        }
    }
}


-- 
Spark Shen
China Software Development Lab, IBM

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message