You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xmlbeans.apache.org by "Wei Yin Teo (JIRA)" <xm...@xml.apache.org> on 2006/02/08 17:07:36 UTC

[jira] Updated: (XMLBEANS-209) Saver$TextSaver.replace method throws java.lang.ArrayIndexOutOfBoundsException

     [ http://issues.apache.org/jira/browse/XMLBEANS-209?page=all ]

Wei Yin Teo updated XMLBEANS-209:
---------------------------------

    Attachment: saver.patch

This happen when a char that is replaced is near the end of the circular buffer, e.g. '&' at i = 16381, _in = 16382, _buf.length = 16384, dCch = 4, replacement = '&amp;'.  System.arraycopy is called with destination index at  'i+dCch' = 16385 which is greater than the buffer length.

Special care must be taken care when the replacement will wrap around the buffer.

Please see the attach diff for the fixes.

> Saver$TextSaver.replace method throws java.lang.ArrayIndexOutOfBoundsException
> ------------------------------------------------------------------------------
>
>          Key: XMLBEANS-209
>          URL: http://issues.apache.org/jira/browse/XMLBEANS-209
>      Project: XMLBeans
>         Type: Bug
>     Versions: Version 2
>  Environment: Java2 RE 1.4 and Java2 RE 5.0
>     Reporter: Koyama Hiroshi
>  Attachments: saver.patch
>
> Stacktrace is as follows.
> java.lang.ArrayIndexOutOfBoundsException
>         at java.lang.System.arraycopy(Native Method)
>         at org.apache.xmlbeans.impl.store.Saver$TextSaver.replace(Saver.java:1438)
>         at org.apache.xmlbeans.impl.store.Saver$TextSaver.entitizeContent(Saver.java:1269)
> (snip)
> I checked each variables.
> 1438:    System.arraycopy( _buf, i, _buf, i + dCch, _in - i );  // i:16358 _in:16381 dcCh:4 _buf.length:16384
> I think _buf has not enough size.
> So, I changed source as follows. 
> 1438:    if (_buf.length < _in+dCch+_in-i)  i = resize( dCch, i);
> 1439:    System.arraycopy( _buf, i, _buf, i + dCch, _in - i );
> This is not good patch, but I can save xml data.
> regards.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: dev-help@xmlbeans.apache.org