Bug 171537 - [PATCH] textproc/xerces-c3: Fix bug in ContentSpecNode and allow compilation using C++11 (Clang)
Summary: [PATCH] textproc/xerces-c3: Fix bug in ContentSpecNode and allow compilation ...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Pietro Cerutti
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-11 12:30 UTC by Michael Gmelin
Modified: 2012-09-12 10:50 UTC (History)
1 user (show)

See Also:


Attachments
xerces-c3-3.1.1_1.patch (8.81 KB, patch)
2012-09-11 12:30 UTC, Michael Gmelin
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Gmelin 2012-09-11 12:30:03 UTC
Fix an operator precedence error in ContentSpecNode::getMaxTotalRange that
leads to wrong max calculation in choices while parsing xml schemata (see
also https://issues.apache.org/jira/browse/XERCESC-1994).

Add static_cast to explicitely narrow down types to allow compilation using
C++11. especially Clang, since it treats those as errors (see also
https://issues.apache.org/jira/browse/XERCESC-1995)

Added file(s):
- files/patch-src-xercesc-util-XMLUTF8Transcoder.cpp
- files/patch-src-xercesc-util-XMLUTF8Transcoder.hpp
- files/patch-src-xercesc-util-regx-ParserForXMLSchema.cpp
- files/patch-src-xercesc-util-regx-RegxParser.cpp
- files/patch-src-xercesc-validators-common-ContentSpecNode.cpp

Port maintainer (gahr@FreeBSD.org) is cc'd.

Generated with FreeBSD Port Tools 0.99_6 (mode: change, diff: suffix)
Comment 1 Edwin Groothuis freebsd_committer freebsd_triage 2012-09-11 12:30:16 UTC
Responsible Changed
From-To: freebsd-ports-bugs->gahr

Over to maintainer (via the GNATS Auto Assign Tool)
Comment 2 dfilter service freebsd_committer freebsd_triage 2012-09-12 10:48:12 UTC
Author: gahr
Date: Wed Sep 12 09:47:56 2012
New Revision: 304141
URL: http://svn.freebsd.org/changeset/ports/304141

Log:
  - Add patches to address upstream the following upstream issues [1]
    * https://issues.apache.org/jira/browse/XERCESC-1994
    * https://issues.apache.org/jira/browse/XERCESC-1995
  - Bump PORTREVISION
  - While at it, add a 'test' target to run the provided test suite
  
  PR:		171537 [1]
  Submitted by:	Michael Gmelin <freebsd@grem.de>

Added:
  head/textproc/xerces-c3/files/
  head/textproc/xerces-c3/files/patch-src-xercesc-util-XMLUTF8Transcoder.cpp   (contents, props changed)
  head/textproc/xerces-c3/files/patch-src-xercesc-util-XMLUTF8Transcoder.hpp   (contents, props changed)
  head/textproc/xerces-c3/files/patch-src-xercesc-util-regx-ParserForXMLSchema.cpp   (contents, props changed)
  head/textproc/xerces-c3/files/patch-src-xercesc-util-regx-RegxParser.cpp   (contents, props changed)
  head/textproc/xerces-c3/files/patch-src-xercesc-validators-common-ContentSpecNode.cpp   (contents, props changed)
Modified:
  head/textproc/xerces-c3/Makefile   (contents, props changed)

Modified: head/textproc/xerces-c3/Makefile
==============================================================================
--- head/textproc/xerces-c3/Makefile	Wed Sep 12 09:06:06 2012	(r304140)
+++ head/textproc/xerces-c3/Makefile	Wed Sep 12 09:47:56 2012	(r304141)
@@ -7,6 +7,7 @@
 
 PORTNAME=	xerces-c3
 PORTVERSION=	3.1.1
+PORTREVISION=	1
 CATEGORIES=	textproc
 MASTER_SITES=	${MASTER_SITE_APACHE}
 MASTER_SITE_SUBDIR=	xerces/c/3/sources
@@ -30,4 +31,7 @@ MAKE_JOBS_UNSAFE=yes
 post-install:
 	${LN} -sf libxerces-c-${PORTVERSION:R}.so ${PREFIX}/lib/libxerces-c.so.${PORTVERSION:R:R}
 
+test:
+	cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} ${MAKE} check
+
 .include <bsd.port.mk>

Added: head/textproc/xerces-c3/files/patch-src-xercesc-util-XMLUTF8Transcoder.cpp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/textproc/xerces-c3/files/patch-src-xercesc-util-XMLUTF8Transcoder.cpp	Wed Sep 12 09:47:56 2012	(r304141)
@@ -0,0 +1,53 @@
+--- src/xercesc/util/XMLUTF8Transcoder.cpp.orig
++++ src/xercesc/util/XMLUTF8Transcoder.cpp
+@@ -178,7 +178,7 @@ XMLUTF8Transcoder::transcodeFrom(const  XMLByte* const          srcData
+         if((gUTFByteIndicatorTest[trailingBytes] & *srcPtr) != gUTFByteIndicator[trailingBytes]) {
+             char pos[2] = {(char)0x31, 0}; 
+             char len[2] = {(char)(trailingBytes+0x31), 0};
+-            char byte[2] = {*srcPtr,0};
++            char byte[2] = {static_cast<char>(*srcPtr),0};
+             ThrowXMLwithMemMgr3(UTFDataFormatException, XMLExcepts::UTF8_FormatError, pos, byte, len, getMemoryManager());
+         }
+ 
+@@ -246,8 +246,8 @@ XMLUTF8Transcoder::transcodeFrom(const  XMLByte* const          srcData
+                 //
+                 if (( *srcPtr == 0xE0) && ( *(srcPtr+1) < 0xA0)) 
+                 {
+-                    char byte0[2] = {*srcPtr    ,0};
+-                    char byte1[2] = {*(srcPtr+1),0};
++                    char byte0[2] = {static_cast<char>(*srcPtr)    ,0};
++                    char byte1[2] = {static_cast<char>(*(srcPtr+1)),0};
+ 
+                     ThrowXMLwithMemMgr2(UTFDataFormatException
+                                       , XMLExcepts::UTF8_Invalid_3BytesSeq
+@@ -284,8 +284,8 @@ XMLUTF8Transcoder::transcodeFrom(const  XMLByte* const          srcData
+ 
+                 if ((*srcPtr == 0xED) && (*(srcPtr+1) >= 0xA0))
+                 {
+-                    char byte0[2] = {*srcPtr,    0};
+-                    char byte1[2] = {*(srcPtr+1),0};
++                    char byte0[2] = {static_cast<char>(*srcPtr),    0};
++                    char byte1[2] = {static_cast<char>(*(srcPtr+1)),0};
+ 
+                      ThrowXMLwithMemMgr2(UTFDataFormatException
+                               , XMLExcepts::UTF8_Irregular_3BytesSeq
+@@ -310,8 +310,8 @@ XMLUTF8Transcoder::transcodeFrom(const  XMLByte* const          srcData
+                 if (((*srcPtr == 0xF0) && (*(srcPtr+1) < 0x90)) ||
+                     ((*srcPtr == 0xF4) && (*(srcPtr+1) > 0x8F))  )
+                 {
+-                    char byte0[2] = {*srcPtr    ,0};
+-                    char byte1[2] = {*(srcPtr+1),0};
++                    char byte0[2] = {static_cast<char>(*srcPtr)    ,0};
++                    char byte1[2] = {static_cast<char>(*(srcPtr+1)),0};
+ 
+                     ThrowXMLwithMemMgr2(UTFDataFormatException
+                                       , XMLExcepts::UTF8_Invalid_4BytesSeq
+@@ -344,7 +344,7 @@ XMLUTF8Transcoder::transcodeFrom(const  XMLByte* const          srcData
+                  * surrogates, nor U+FFFE and U+FFFF (but it does allow other noncharacters).
+                  ***/
+                 char len[2]  = {(char)(trailingBytes+0x31), 0};
+-                char byte[2] = {*srcPtr,0};
++                char byte[2] = {static_cast<char>(*srcPtr),0};
+ 
+                 ThrowXMLwithMemMgr2(UTFDataFormatException
+                                   , XMLExcepts::UTF8_Exceeds_BytesLimit

Added: head/textproc/xerces-c3/files/patch-src-xercesc-util-XMLUTF8Transcoder.hpp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/textproc/xerces-c3/files/patch-src-xercesc-util-XMLUTF8Transcoder.hpp	Wed Sep 12 09:47:56 2012	(r304141)
@@ -0,0 +1,11 @@
+--- src/xercesc/util/XMLUTF8Transcoder.hpp.orig
++++ src/xercesc/util/XMLUTF8Transcoder.hpp
+@@ -107,7 +107,7 @@ void XMLUTF8Transcoder::checkTrailingBytes(const XMLByte      toCheck
+     {
+         char len[2]  = {(char)(trailingBytes+0x31), 0};
+         char pos[2]  = {(char)(position+0x31), 0};
+-        char byte[2] = {toCheck,0};
++        char byte[2] = {static_cast<char>(toCheck),0};
+         ThrowXMLwithMemMgr3(UTFDataFormatException, XMLExcepts::UTF8_FormatError, pos, byte, len, getMemoryManager());
+     }
+ 

Added: head/textproc/xerces-c3/files/patch-src-xercesc-util-regx-ParserForXMLSchema.cpp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/textproc/xerces-c3/files/patch-src-xercesc-util-regx-ParserForXMLSchema.cpp	Wed Sep 12 09:47:56 2012	(r304141)
@@ -0,0 +1,11 @@
+--- src/xercesc/util/regx/ParserForXMLSchema.cpp.orig
++++ src/xercesc/util/regx/ParserForXMLSchema.cpp
+@@ -156,7 +156,7 @@ XMLInt32 ParserForXMLSchema::decodeEscaped() {
+         break;
+     default:
+         {
+-        XMLCh chString[] = {chBackSlash, ch, chNull};        
++        XMLCh chString[] = {chBackSlash, static_cast<XMLCh>(ch), chNull};        
+         ThrowXMLwithMemMgr1(ParseException,XMLExcepts::Parser_Process2, chString, getMemoryManager());
+         }
+     }

Added: head/textproc/xerces-c3/files/patch-src-xercesc-util-regx-RegxParser.cpp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/textproc/xerces-c3/files/patch-src-xercesc-util-regx-RegxParser.cpp	Wed Sep 12 09:47:56 2012	(r304141)
@@ -0,0 +1,43 @@
+--- src/xercesc/util/regx/RegxParser.cpp.orig
++++ src/xercesc/util/regx/RegxParser.cpp
+@@ -691,11 +691,11 @@ RangeToken* RegxParser::parseCharacterClass(const bool useNRange) {
+                     || (ch == chDash && getCharData() == chCloseSquare && firstLoop))) {
+                 // if regex = [-] then invalid...
+                 // '[', ']', '-' not allowed and should be escaped
+-                XMLCh chStr[] = { ch, chNull };
++                XMLCh chStr[] = { static_cast<XMLCh>(ch), chNull };
+                 ThrowXMLwithMemMgr2(ParseException,XMLExcepts::Parser_CC6, chStr, chStr, getMemoryManager());
+             }
+             if (ch == chDash && getCharData() == chDash && getState() != REGX_T_BACKSOLIDUS && !wasDecoded) {
+-                XMLCh chStr[] = { ch, chNull };
++                XMLCh chStr[] = { static_cast<XMLCh>(ch), chNull };
+                 ThrowXMLwithMemMgr2(ParseException,XMLExcepts::Parser_CC6, chStr, chStr, getMemoryManager());
+             }
+ 
+@@ -720,7 +720,7 @@ RangeToken* RegxParser::parseCharacterClass(const bool useNRange) {
+                 else {
+ 
+                     XMLInt32 rangeEnd = getCharData();
+-                    XMLCh rangeEndStr[] = { rangeEnd, chNull };
++                    XMLCh rangeEndStr[] = { static_cast<XMLCh>(rangeEnd), chNull };
+ 
+                     if (type == REGX_T_CHAR) {
+ 
+@@ -737,7 +737,7 @@ RangeToken* RegxParser::parseCharacterClass(const bool useNRange) {
+                     processNext();
+ 
+                     if (ch > rangeEnd) {
+-                        XMLCh chStr[] = { ch, chNull };
++                        XMLCh chStr[] = { static_cast<XMLCh>(ch), chNull };
+                         ThrowXMLwithMemMgr2(ParseException,XMLExcepts::Parser_Ope3, rangeEndStr, chStr, getMemoryManager());
+                     }
+ 
+@@ -845,7 +845,7 @@ XMLInt32 RegxParser::decodeEscaped() {
+         break;
+     default:
+     {
+-        XMLCh chString[] = {chBackSlash, ch, chNull};        
++        XMLCh chString[] = {chBackSlash, static_cast<XMLCh>(ch), chNull};        
+         ThrowXMLwithMemMgr1(ParseException,XMLExcepts::Parser_Process2, chString, getMemoryManager());
+     }
+     }

Added: head/textproc/xerces-c3/files/patch-src-xercesc-validators-common-ContentSpecNode.cpp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/textproc/xerces-c3/files/patch-src-xercesc-validators-common-ContentSpecNode.cpp	Wed Sep 12 09:47:56 2012	(r304141)
@@ -0,0 +1,11 @@
+--- orig/xercesc/validators/common/ContentSpecNode.cpp.orig
++++ src/xercesc/validators/common/ContentSpecNode.cpp
+@@ -259,7 +259,7 @@ int ContentSpecNode::getMaxTotalRange() const {
+             else {
+ 
+                 if ((fType & 0x0f) == ContentSpecNode::Choice) {
+-                    max = max * (maxFirst > maxSecond) ? maxFirst : maxSecond;
++                    max = max * ((maxFirst > maxSecond) ? maxFirst : maxSecond);
+                 }
+                 else {
+                     max = max * (maxFirst + maxSecond);
_______________________________________________
svn-ports-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-ports-all
To unsubscribe, send any mail to "svn-ports-all-unsubscribe@freebsd.org"
Comment 3 Pietro Cerutti freebsd_committer freebsd_triage 2012-09-12 10:48:51 UTC
State Changed
From-To: open->closed

Committed. Thanks!