Erlang/OTP Forums

Author Message

<  Erlang bugs mailing list  ~  Bug in jinterface

vladdu
Posted: Mon Aug 22, 2005 7:36 pm Reply with quote
User Joined: 28 Feb 2005 Posts: 397 Location: Gothenburg, Sweden
Hi,

The OtpOutputStream implementation in jinterface is not conforming to the
external distribution format: method write_string doesn't check if the
length is >= 65536, when the sitring should be output with a listTag, not a
stringTag.

The patch is (sorry, but I have a modified version of the file and the line
numbers don't match)

- if (bytebuf.length == len && len < 65535)
+ if (bytebuf.length == len)

regards,
Vlad


Post generated using Mail2Forum (http://m2f.sourceforge.net)
View user's profile Send private message
raimo at erix.ericsson.se
Posted: Tue Aug 23, 2005 10:31 am Reply with quote
Guest
This bug is fixed in R10B (jinterface-1.3) and later:

public void write_string(String s) {
int len = s.length();

switch(len) {
case 0:
this.write_nil();
break;
default:
byte[] bytebuf = s.getBytes();

/* switch to se if the length of
the byte array is equal to the
length of the list, or if the string is too long
for the stream protocol */
if ((bytebuf.length == len) && (len <= 65535)) { /* Usual */
this.write1(OtpExternal.stringTag);
this.write2BE(len);
this.writeN(bytebuf);
}
else { /* Unicode */
char[] charbuf = s.toCharArray();

this.write_list_head(len);

for(int i = 0; i<len; i++)
this.write_char(charbuf[i]);

this.write_nil();
}
}
}

Thank you for finding it anyway!



vlad_dumitrescu_at_hotmail.com (Vlad Dumitrescu) writes:

> Hi,
>
> The OtpOutputStream implementation in jinterface is not conforming to
> the external distribution format: method write_string doesn't check if
> the length is >= 65536, when the sitring should be output with a
> listTag, not a stringTag.
>
> The patch is (sorry, but I have a modified version of the file and the
> line numbers don't match)
>
> - if (bytebuf.length == len && len < 65535)
> + if (bytebuf.length == len)
>
> regards,
> Vlad
>

--

/ Raimo Niskanen, Erlang/OTP, Ericsson AB


Post generated using Mail2Forum (http://m2f.sourceforge.net)

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum