Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6374239
Votes 0
Synopsis validation for surrogate pair is incorrect in XMLSerializer and XML11Serializer
Category jaxp:other
Reported Against
Release Fixed 1.3
State 10-Fix Delivered, bug
Priority: 4-Low
Related Bugs
Submit Date 19-JAN-2006
Description
When start >= length a fatal error was emitted for surrogate characters.
  Since length is decremented on each loop and since start is an offset which
  doesn't necessarily start from zero this comparison isn't valid. Should be
  fixed now.
  
  Revision  Changes    Path
  1.11      +7 -10     xml-xerces/java/src/org/ customer /xml/serialize/XML11Serializer.java
  
  Index: XML11Serializer.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/ customer /xml/serialize/XML11Serializer.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- XML11Serializer.java	14 May 2004 19:37:53 -0000	1.10
  +++ XML11Serializer.java	18 Apr 2005 04:54:06 -0000	1.11
  @@ -482,12 +482,11 @@
               // consolidating spaces. If a line terminator is used, a line
               // break will occur.
               while ( length-- > 0 ) {
  -                ch = chars[ start ];
  -                ++start;
  +                ch = chars[start++];
                   if (!XML11Char.isXML11Valid(ch)) {
                       // check if it is surrogate
  -                    if (++start <length) {
  -                        surrogates(ch, chars[start]);
  +                    if ( length-- > 0) {
  +                        surrogates(ch, chars[start++]);
                       } else {
                           fatalError("The character '"+(char)ch+"' is an invalid XML character");

                       }
  @@ -505,13 +504,11 @@
               // by printing mechanism. Line terminator is treated
               // no different than other text part.
               while ( length-- > 0 ) {
  -                ch = chars[ start ];
  -                ++start;
  -
  +                ch = chars[start++];
                   if (!XML11Char.isXML11Valid(ch)) {
                       // check if it is surrogate
  -                    if (++start <length) {
  -                        surrogates(ch, chars[start]);
  +                    if ( length-- > 0) {
  +                        surrogates(ch, chars[start++]);
                       } else {
                           fatalError("The character '"+(char)ch+"' is an invalid XML character");

                       }
  
  
  
  1.65      +7 -10     xml-xerces/java/src/org/ customer /xml/serialize/XMLSerializer.java
  
  Index: XMLSerializer.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/ customer /xml/serialize/XMLSerializer.java,v
  retrieving revision 1.64
  retrieving revision 1.65
  diff -u -r1.64 -r1.65
  --- XMLSerializer.java	10 Feb 2005 19:37:21 -0000	1.64
  +++ XMLSerializer.java	18 Apr 2005 04:54:06 -0000	1.65
  @@ -1338,12 +1338,11 @@
               // consolidating spaces. If a line terminator is used, a line
               // break will occur.
               while ( length-- > 0 ) {
  -                ch = chars[ start ];
  -                ++start;
  +                ch = chars[start++];
                   if (!XMLChar.isValid(ch)) {
                       // check if it is surrogate
  -                    if (++start <length) {
  -                        surrogates(ch, chars[start]);
  +                    if ( length-- > 0 ) {
  +                        surrogates(ch, chars[start++]);
                       } else {
                           fatalError("The character '"+(char)ch+"' is an invalid XML character");

                       }
  @@ -1361,13 +1360,11 @@
               // by printing mechanism. Line terminator is treated
               // no different than other text part.
               while ( length-- > 0 ) {
  -                ch = chars[ start ];
  -                ++start;
  -
  +                ch = chars[start++];
                   if (!XMLChar.isValid(ch)) {
                       // check if it is surrogate
  -                    if (++start <length) {
  -                        surrogates(ch, chars[start]);
  +                    if ( length-- > 0 ) {
  +                        surrogates(ch, chars[start++]);
                       } else {
                           fatalError("The character '"+(char)ch+"' is an invalid XML character");

                       }
Posted Date : 2006-01-19 10:58:54.0
Work Around
N/A
Evaluation
this has been fix in JAXP 1.3.2 available on java.net:

	http://jaxp.dev.java.net/
Posted Date : 2006-02-07 21:37:09.0
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang