[
http://jira.jboss.com/jira/browse/JBSER-93?page=comments#action_12353002 ]
Clebert Suconic commented on JBSER-93:
--------------------------------------
Thanks Andrei...
This is a duplicate of JBSER-89
My error was to not put the release (1.0.3) on
www.jboss.org also. The release is only
available at Sourceforge:
http://sourceforge.net/project/showfiles.php?group_id=22866&package_i...
I'm uploading the release on
jboss.org also.. my apologies.
StringUtil.saveString()/.readString() length bug
-------------------------------------------------
Key: JBSER-93
URL:
http://jira.jboss.com/jira/browse/JBSER-93
Project: JBoss Serialization
Issue Type: Bug
Reporter: Andrei Chiritescu
Assigned To: Clebert Suconic
Attachments: StringUtilTest.java
In the StringUtil.saveString() method the length is saved using the following code :
<code>
if (len>0xffff)
{
out.writeBoolean(true); // the size is bigger than a short value
out.writeLong(len);
}
else
{
out.writeBoolean(false);
out.writeShort((short)len);
}
</code>
.... and in the StringUtil.readString() the length is read using :
<code>
boolean isLong = input.readBoolean();
if (isLong)
{
size = input.readLong();
}
else
{
size = input.readShort();
}
</code>
The problem is with string that have a length between '7FFF' and 'FFFF' -
they will have the length stored as a short but when the length will be read for
deserialization readShort() will return a negative number.
To fix this you'll have to either use 7FFF instead of FFFF in the saveString() when
comparing or use 'size = input.readUnsignedShort();' when reading the length in
the readString().
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira