Still a problem in 3.1.1. Patch included.

Regards,

Denis Excoffier.

On Tue, Nov 03, 2009 at 09:36:00AM +0000, Boris Kolpackov (JIRA) wrote:
>> 
>>      [ 
>> https://issues.apache.org/jira/browse/XERCESC-1701?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
>>  ]
>> 
>> Boris Kolpackov updated XERCESC-1701:
>> -------------------------------------
>> 
>>     Affects Version/s:     (was: 2.7.0)
>>                        3.0.1
>> 
>> Still a problem in 3.0.1.
>> 
>> > Xerces-C++ Allows junk after root element (null characters)
>> > -----------------------------------------------------------
>> >
>> >                 Key: XERCESC-1701
>> >                 URL: https://issues.apache.org/jira/browse/XERCESC-1701
>> >             Project: Xerces-C++
>> >          Issue Type: Bug
>> >          Components: Non-Validating Parser
>> >    Affects Versions: 3.0.1
>> >         Environment: WindowsXP
>> >            Reporter: Maarten Koskamp
>> >         Attachments: sample.xml, version.incl
>> >
>> >
>> > Xerces-C allows a sequence of null characters after the document root at 
>> > the end of the xml instance.
>> > XML Specifiction states that only white-space is allowed after the 
>> > document root. 
>> > See attached sample for details.
>> > Info about the affected version of the parser is also added as an 
>> > attachment to this issue.
>> 
>> -- 
>> This message is automatically generated by JIRA.
>> -
>> You can reply to this email to add a comment to the issue online.
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>> 
>> 
>> 
diff -uNr xerces-c-3.1.1o/src/xercesc/internal/DGXMLScanner.cpp 
xerces-c-3.1.1p/src/xercesc/internal/DGXMLScanner.cpp
--- xerces-c-3.1.1o/src/xercesc/internal/DGXMLScanner.cpp       2009-11-05 
14:21:03.000000000 +0059
+++ xerces-c-3.1.1p/src/xercesc/internal/DGXMLScanner.cpp       2012-08-06 
10:45:26.765625000 +0159
@@ -1407,7 +1407,7 @@
 
         //  It was some special case character so do all of the checks and
         //  deal with it.
-        if (!nextCh)
+        if (!nextCh && fReaderMgr.atEOF())
             ThrowXMLwithMemMgr(UnexpectedEOFException, 
XMLExcepts::Gen_UnexpectedEOF, fMemoryManager);
 
         if (nextCh == chForwardSlash)
@@ -1858,7 +1858,7 @@
 
         //  It was some special case character so do all of the checks and
         //  deal with it.
-        if (!nextCh)
+        if (!nextCh && fReaderMgr.atEOF())
             ThrowXMLwithMemMgr(UnexpectedEOFException, 
XMLExcepts::Gen_UnexpectedEOF, fMemoryManager);
 
         if (nextCh == chForwardSlash)
@@ -2812,7 +2812,7 @@
         {
             nextCh = fReaderMgr.getNextChar();
 
-            if (!nextCh)
+            if (!nextCh && fReaderMgr.atEOF())
                 ThrowXMLwithMemMgr(UnexpectedEOFException, 
XMLExcepts::Gen_UnexpectedEOF, fMemoryManager);
 
             // Check for our ending quote in the same entity
@@ -3021,7 +3021,7 @@
         const XMLCh nextCh = fReaderMgr.getNextChar();
 
         // Watch for unexpected end of file
-        if (!nextCh)
+        if (!nextCh && fReaderMgr.atEOF())
         {
             emitError(XMLErrs::UnterminatedCDATASection);
             ThrowXMLwithMemMgr(UnexpectedEOFException, 
XMLExcepts::Gen_UnexpectedEOF, fMemoryManager);
diff -uNr xerces-c-3.1.1o/src/xercesc/internal/IGXMLScanner.cpp 
xerces-c-3.1.1p/src/xercesc/internal/IGXMLScanner.cpp
--- xerces-c-3.1.1o/src/xercesc/internal/IGXMLScanner.cpp       2009-11-20 
14:43:50.000000000 +0059
+++ xerces-c-3.1.1p/src/xercesc/internal/IGXMLScanner.cpp       2012-08-06 
10:46:25.703125000 +0159
@@ -762,7 +762,7 @@
 
         //  It was some special case character so do all of the checks and
         //  deal with it.
-        if (!nextCh)
+        if (!nextCh && fReaderMgr.atEOF())
             ThrowXMLwithMemMgr(UnexpectedEOFException, 
XMLExcepts::Gen_UnexpectedEOF, fMemoryManager);
 
         if (nextCh == chForwardSlash)
@@ -1910,7 +1910,7 @@
 
         //  It was some special case character so do all of the checks and
         //  deal with it.
-        if (!nextCh)
+        if (!nextCh && fReaderMgr.atEOF())
             ThrowXMLwithMemMgr(UnexpectedEOFException, 
XMLExcepts::Gen_UnexpectedEOF, fMemoryManager);
 
         if (nextCh == chForwardSlash)
diff -uNr xerces-c-3.1.1o/src/xercesc/internal/IGXMLScanner2.cpp 
xerces-c-3.1.1p/src/xercesc/internal/IGXMLScanner2.cpp
--- xerces-c-3.1.1o/src/xercesc/internal/IGXMLScanner2.cpp      2010-03-19 
15:29:23.000000000 +0059
+++ xerces-c-3.1.1p/src/xercesc/internal/IGXMLScanner2.cpp      2012-08-06 
10:47:39.468750000 +0159
@@ -2271,7 +2271,7 @@
                             // Its got to at least be a valid XML character
                             if 
(!fReaderMgr.getCurrentReader()->isXMLChar(nextCh))
                             {
-                                if (nextCh == 0)
+                                if (nextCh == 0 && fReaderMgr.atEOF())
                                     ThrowXMLwithMemMgr(UnexpectedEOFException, 
XMLExcepts::Gen_UnexpectedEOF, fMemoryManager);
 
                                 XMLCh tmpBuf[9];
@@ -2414,7 +2414,7 @@
             {
                 nextCh = fReaderMgr.getNextChar();
 
-                if (!nextCh)
+                if (!nextCh && fReaderMgr.atEOF())
                     ThrowXMLwithMemMgr(UnexpectedEOFException, 
XMLExcepts::Gen_UnexpectedEOF, fMemoryManager);
 
                 // Check for our ending quote in the same entity
@@ -2638,7 +2638,7 @@
         const XMLCh nextCh = fReaderMgr.getNextChar();
 
         // Watch for unexpected end of file
-        if (!nextCh)
+        if (!nextCh && fReaderMgr.atEOF())
         {
             emitError(XMLErrs::UnterminatedCDATASection);
             ThrowXMLwithMemMgr(UnexpectedEOFException, 
XMLExcepts::Gen_UnexpectedEOF, fMemoryManager);
diff -uNr xerces-c-3.1.1o/src/xercesc/internal/ReaderMgr.cpp 
xerces-c-3.1.1p/src/xercesc/internal/ReaderMgr.cpp
--- xerces-c-3.1.1o/src/xercesc/internal/ReaderMgr.cpp  2009-11-05 
14:21:03.000000000 +0059
+++ xerces-c-3.1.1p/src/xercesc/internal/ReaderMgr.cpp  2012-08-06 
10:48:39.156250000 +0159
@@ -279,7 +279,7 @@
 {
     XMLCh nextCh;
     // If we get an end of file char, then return
-    while ((nextCh = getNextChar())!=0)
+    while ((nextCh = getNextChar())!=0 || !atEOF())
     {
         // If we get the quote char, then break out
         if (nextCh == quoteCh)
@@ -292,7 +292,7 @@
 {
     XMLCh nextCh;
     // If we get an end of file char, then return
-    while ((nextCh = peekNextChar())!=0)
+    while ((nextCh = peekNextChar())!=0 || !atEOF())
     {
         if (XMLString::indexOf(listToSkip, nextCh) != -1)
             break;
@@ -308,7 +308,7 @@
 {
     XMLCh nextCh;
     // If we get an end of file char, then return
-    while ((nextCh = peekNextChar())!=0)
+    while ((nextCh = peekNextChar())!=0 || !atEOF())
     {
         if (fCurReader->isWhitespace(nextCh))
             break;
diff -uNr xerces-c-3.1.1o/src/xercesc/internal/ReaderMgr.hpp 
xerces-c-3.1.1p/src/xercesc/internal/ReaderMgr.hpp
--- xerces-c-3.1.1o/src/xercesc/internal/ReaderMgr.hpp  2009-11-05 
14:21:03.000000000 +0059
+++ xerces-c-3.1.1p/src/xercesc/internal/ReaderMgr.hpp  2012-08-06 
10:49:51.062500000 +0159
@@ -366,7 +366,7 @@
         nextCh = getNextChar();
        }
     // Break out at end of input or the char to skip
-       while((nextCh != toSkipTo) && nextCh!=0);
+       while((nextCh != toSkipTo) && (nextCh!=0 || !atEOF()));
 }
 
 inline void ReaderMgr::skipPastChar(const XMLCh toSkipPast)
@@ -377,7 +377,7 @@
         // Get chars until we find the one to skip
         nextCh = getNextChar();
        }
-       while((nextCh != toSkipPast) && nextCh!=0);
+       while((nextCh != toSkipPast) && (nextCh!=0 || !atEOF()));
 }
 
 inline bool ReaderMgr::peekString(const XMLCh* const toPeek)
diff -uNr xerces-c-3.1.1o/src/xercesc/internal/SGXMLScanner.cpp 
xerces-c-3.1.1p/src/xercesc/internal/SGXMLScanner.cpp
--- xerces-c-3.1.1o/src/xercesc/internal/SGXMLScanner.cpp       2010-03-19 
15:29:23.000000000 +0059
+++ xerces-c-3.1.1p/src/xercesc/internal/SGXMLScanner.cpp       2012-08-06 
10:50:53.609375000 +0159
@@ -680,7 +680,7 @@
 
         //  It was some special case character so do all of the checks and
         //  deal with it.
-        if (!nextCh)
+        if (!nextCh && fReaderMgr.atEOF())
             ThrowXMLwithMemMgr(UnexpectedEOFException, 
XMLExcepts::Gen_UnexpectedEOF, fMemoryManager);
 
         if (nextCh == chForwardSlash)
@@ -4063,7 +4063,7 @@
                             // Its got to at least be a valid XML character
                             if 
(!fReaderMgr.getCurrentReader()->isXMLChar(nextCh))
                             {
-                                if (nextCh == 0)
+                                if (nextCh == 0 && fReaderMgr.atEOF())
                                     ThrowXMLwithMemMgr(UnexpectedEOFException, 
XMLExcepts::Gen_UnexpectedEOF, fMemoryManager);
 
                                 XMLCh tmpBuf[9];
@@ -4212,7 +4212,7 @@
         const XMLCh nextCh = fReaderMgr.getNextChar();
 
         // Watch for unexpected end of file
-        if (!nextCh)
+        if (!nextCh && fReaderMgr.atEOF())
         {
             emitError(XMLErrs::UnterminatedCDATASection);
             ThrowXMLwithMemMgr(UnexpectedEOFException, 
XMLExcepts::Gen_UnexpectedEOF, fMemoryManager);
diff -uNr xerces-c-3.1.1o/src/xercesc/internal/WFXMLScanner.cpp 
xerces-c-3.1.1p/src/xercesc/internal/WFXMLScanner.cpp
--- xerces-c-3.1.1o/src/xercesc/internal/WFXMLScanner.cpp       2009-11-05 
14:21:03.000000000 +0059
+++ xerces-c-3.1.1p/src/xercesc/internal/WFXMLScanner.cpp       2012-08-06 
10:51:52.234375000 +0159
@@ -980,7 +980,7 @@
 
         //  It was some special case character so do all of the checks and
         //  deal with it.
-        if (!nextCh)
+        if (!nextCh && fReaderMgr.atEOF())
             ThrowXMLwithMemMgr(UnexpectedEOFException, 
XMLExcepts::Gen_UnexpectedEOF, fMemoryManager);
 
         if (nextCh == chForwardSlash)
@@ -1359,7 +1359,7 @@
 
         //  It was some special case character so do all of the checks and
         //  deal with it.
-        if (!nextCh)
+        if (!nextCh && fReaderMgr.atEOF())
             ThrowXMLwithMemMgr(UnexpectedEOFException, 
XMLExcepts::Gen_UnexpectedEOF, fMemoryManager);
 
         if (nextCh == chForwardSlash)
@@ -1535,7 +1535,7 @@
         {
             nextCh = fReaderMgr.getNextChar();
 
-            if (!nextCh)
+            if (!nextCh && fReaderMgr.atEOF())
                 ThrowXMLwithMemMgr(UnexpectedEOFException, 
XMLExcepts::Gen_UnexpectedEOF, fMemoryManager);
 
             // Check for our ending quote in the same entity
@@ -1680,7 +1680,7 @@
         const XMLCh nextCh = fReaderMgr.getNextChar();
 
         // Watch for unexpected end of file
-        if (!nextCh)
+        if (!nextCh && fReaderMgr.atEOF())
         {
             emitError(XMLErrs::UnterminatedCDATASection);
             ThrowXMLwithMemMgr(UnexpectedEOFException, 
XMLExcepts::Gen_UnexpectedEOF, fMemoryManager);
diff -uNr xerces-c-3.1.1o/src/xercesc/internal/XMLScanner.cpp 
xerces-c-3.1.1p/src/xercesc/internal/XMLScanner.cpp
--- xerces-c-3.1.1o/src/xercesc/internal/XMLScanner.cpp 2009-11-20 
14:43:50.000000000 +0059
+++ xerces-c-3.1.1p/src/xercesc/internal/XMLScanner.cpp 2012-08-06 
10:53:06.437500000 +0159
@@ -1010,7 +1010,7 @@
             const XMLCh nextCh = fReaderMgr.peekNextChar();
 
             // Watch for end of file and break out
-            if (!nextCh)
+            if (!nextCh && fReaderMgr.atEOF())
                 break;
 
             if (nextCh == chOpenAngle)
@@ -1130,7 +1130,7 @@
             const XMLCh nextCh = fReaderMgr.getNextChar();
 
             // Watch for an end of file, which is always bad here
-            if (!nextCh)
+            if (!nextCh && fReaderMgr.atEOF())
             {
                 emitError(XMLErrs::UnterminatedPI);
                 ThrowXMLwithMemMgr(UnexpectedEOFException, 
XMLExcepts::Gen_UnexpectedEOF, fMemoryManager);
@@ -1310,7 +1310,7 @@
                 emitError(XMLErrs::InvalidDocumentStructure);
 
                 // Watch for end of file and break out
-                if (!nextCh)
+                if (!nextCh && fReaderMgr.atEOF())
                     break;
                 else
                     fReaderMgr.skipPastChar(chCloseAngle);
@@ -1971,7 +1971,7 @@
         //  We should never get either an end of file null char here. If we
         //  do, just fail. It will be handled more gracefully in the higher
         //  level code that called us.
-        if (!nextCh)
+        if (!nextCh && fReaderMgr.atEOF())
             return false;
 
         // Else add it to the buffer
@@ -2008,7 +2008,7 @@
         const XMLCh nextCh = fReaderMgr.peekNextChar();
 
         // Watch for EOF
-        if (!nextCh)
+        if (!nextCh && fReaderMgr.atEOF())
             ThrowXMLwithMemMgr(UnexpectedEOFException, 
XMLExcepts::Gen_UnexpectedEOF, fMemoryManager);
 
         // Break out on the terminating semicolon
@@ -2128,7 +2128,7 @@
         const XMLCh nextCh = fReaderMgr.getNextChar();
 
         //  Watch for an end of file
-        if (!nextCh)
+        if (!nextCh && fReaderMgr.atEOF())
         {
             emitError(XMLErrs::UnterminatedComment);
             ThrowXMLwithMemMgr(UnexpectedEOFException, 
XMLExcepts::Gen_UnexpectedEOF, fMemoryManager);
diff -uNr xerces-c-3.1.1o/src/xercesc/validators/DTD/DTDScanner.cpp 
xerces-c-3.1.1p/src/xercesc/validators/DTD/DTDScanner.cpp
--- xerces-c-3.1.1o/src/xercesc/validators/DTD/DTDScanner.cpp   2009-11-05 
14:21:03.000000000 +0059
+++ xerces-c-3.1.1p/src/xercesc/validators/DTD/DTDScanner.cpp   2012-08-06 
10:55:04.921875000 +0159
@@ -387,7 +387,7 @@
         //  do, just fail. It will be handled more gracefully in the higher
         //  level code that called us.
         //
-        if (!nextCh)
+        if (!nextCh && fReaderMgr->atEOF())
             return false;
 
         // Else add it to the buffer
@@ -652,7 +652,7 @@
         const XMLCh nextCh = fReaderMgr->peekNextChar();
 
         // Watch for EOF
-        if (!nextCh)
+        if (!nextCh && fReaderMgr->atEOF())
             ThrowXMLwithMemMgr(UnexpectedEOFException, 
XMLExcepts::Gen_UnexpectedEOF, fMemoryManager);
 
         if (nextCh == chCloseAngle)
@@ -781,7 +781,7 @@
         {
             nextCh = fReaderMgr->getNextChar();
 
-            if (!nextCh)
+            if (!nextCh && fReaderMgr->atEOF())
                 ThrowXMLwithMemMgr(UnexpectedEOFException, 
XMLExcepts::Gen_UnexpectedEOF, fMemoryManager);
 
             // Check for our ending quote in the same entity
@@ -950,7 +950,7 @@
         const XMLCh nextCh = fReaderMgr->peekNextChar();
 
         // Watch for EOF
-        if (!nextCh)
+        if (!nextCh && fReaderMgr->atEOF())
             ThrowXMLwithMemMgr(UnexpectedEOFException, 
XMLExcepts::Gen_UnexpectedEOF, fMemoryManager);
 
         // Break out on the terminating semicolon
@@ -1426,7 +1426,7 @@
         const XMLCh nextCh = fReaderMgr->getNextChar();
 
         //  Watch for an end of file
-        if (!nextCh)
+        if (!nextCh && fReaderMgr->atEOF())
         {
             fScanner->emitError(XMLErrs::UnterminatedComment);
             ThrowXMLwithMemMgr(UnexpectedEOFException, 
XMLExcepts::Gen_UnexpectedEOF, fMemoryManager);
@@ -2126,7 +2126,7 @@
         //  if that occurs (since an unterminated quoted char can cause
         //  this easily.)
         //
-        if (!nextCh)
+        if (!nextCh && fReaderMgr->atEOF())
         {
             fScanner->emitError(XMLErrs::UnterminatedEntityLiteral);
             ThrowXMLwithMemMgr(UnexpectedEOFException, 
XMLExcepts::Gen_UnexpectedEOF, fMemoryManager);
@@ -2511,7 +2511,7 @@
             {
                 const XMLCh nextCh = fReaderMgr->peekNextChar();
 
-                if (!nextCh)
+                if (!nextCh && fReaderMgr->atEOF())
                 {
                     return; // nothing left
                 }
@@ -2832,7 +2832,7 @@
     {
         const XMLCh nextCh = fReaderMgr->getNextChar();
 
-        if (!nextCh)
+        if (!nextCh && fReaderMgr->atEOF())
             ThrowXMLwithMemMgr(UnexpectedEOFException, 
XMLExcepts::Gen_UnexpectedEOF, fMemoryManager);
 
         if (nextCh == chOpenAngle)
@@ -2939,7 +2939,7 @@
         //  failure status. The caller will then see the end of file and
         //  faill out correctly.
         //
-        if (!nextCh)
+        if (!nextCh && fReaderMgr->atEOF())
             return false;
 
         // Watch for the end of internal subset marker
@@ -3599,7 +3599,7 @@
             const XMLCh nextCh = fReaderMgr->getNextChar();
 
             // Watch for an end of file, which is always bad here
-            if (!nextCh)
+            if (!nextCh && fReaderMgr->atEOF())
             {
                 fScanner->emitError(XMLErrs::UnterminatedPI);
                 ThrowXMLwithMemMgr(UnexpectedEOFException, 
XMLExcepts::Gen_UnexpectedEOF, fMemoryManager);
@@ -3704,7 +3704,7 @@
         const XMLCh nextCh = fReaderMgr->getNextChar();
 
         // Watch for EOF
-        if (!nextCh)
+        if (!nextCh && fReaderMgr->atEOF())
             ThrowXMLwithMemMgr(UnexpectedEOFException, 
XMLExcepts::Gen_UnexpectedEOF, fMemoryManager);
 
         if (nextCh == quoteCh)
@@ -3755,7 +3755,7 @@
     while ((nextCh=fReaderMgr->getNextChar())!=quoteCh)
     {
         // Watch for EOF
-        if (!nextCh)
+        if (!nextCh && fReaderMgr->atEOF())
             ThrowXMLwithMemMgr(UnexpectedEOFException, 
XMLExcepts::Gen_UnexpectedEOF, fMemoryManager);
         toFill.append(nextCh);
     }

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to