mrglavas 2003/10/22 11:33:43 Modified: java/src/org/apache/xerces/impl XML11NSDocumentScannerImpl.java XMLNSDocumentScannerImpl.java XMLDocumentFragmentScannerImpl.java Log: Fixing potential AIOOBEs and NPEs that can occur when the continue-after-fatal-error feature is set to true, and an attribute specification contains duplicate names. Revision Changes Path 1.4 +14 -11 xml-xerces/java/src/org/apache/xerces/impl/XML11NSDocumentScannerImpl.java Index: XML11NSDocumentScannerImpl.java =================================================================== RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/XML11NSDocumentScannerImpl.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- XML11NSDocumentScannerImpl.java 10 Oct 2003 18:25:40 -0000 1.3 +++ XML11NSDocumentScannerImpl.java 22 Oct 2003 18:33:43 -0000 1.4 @@ -377,18 +377,21 @@ fEntityScanner.skipSpaces(); // content - int oldLen = attributes.getLength(); + int attrIndex; if (fBindNamespaces) { + attrIndex = attributes.getLength(); attributes.addAttributeNS( fAttributeQName, XMLSymbols.fCDATASymbol, null); } else { - attributes.addAttribute( - fAttributeQName, - XMLSymbols.fCDATASymbol, - null); + int oldLen = attributes.getLength(); + attrIndex = + attributes.addAttribute( + fAttributeQName, + XMLSymbols.fCDATASymbol, + null); // WFC: Unique Att Spec if (oldLen == attributes.getLength()) { @@ -409,13 +412,13 @@ fTempString2, fAttributeQName.rawname, attributes, - oldLen, + attrIndex, isVC, fCurrentElement.rawname); String value = fTempString.toString(); - attributes.setValue(oldLen, value); - attributes.setNonNormalizedValue(oldLen, fTempString2.toString()); - attributes.setSpecified(oldLen, true); + attributes.setValue(attrIndex, value); + attributes.setNonNormalizedValue(attrIndex, fTempString2.toString()); + attributes.setSpecified(attrIndex, true); // record namespace declarations if any. if (fBindNamespaces) { @@ -487,14 +490,14 @@ uri.length() != 0 ? uri : null); // bind namespace attribute to a namespace attributes.setURI( - oldLen, + attrIndex, fNamespaceContext.getURI(XMLSymbols.PREFIX_XMLNS)); } else { // attempt to bind attribute if (fAttributeQName.prefix != null) { attributes.setURI( - oldLen, + attrIndex, fNamespaceContext.getURI(fAttributeQName.prefix)); } } 1.18 +12 -10 xml-xerces/java/src/org/apache/xerces/impl/XMLNSDocumentScannerImpl.java Index: XMLNSDocumentScannerImpl.java =================================================================== RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/XMLNSDocumentScannerImpl.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- XMLNSDocumentScannerImpl.java 10 Oct 2003 18:25:40 -0000 1.17 +++ XMLNSDocumentScannerImpl.java 22 Oct 2003 18:33:43 -0000 1.18 @@ -387,13 +387,15 @@ fEntityScanner.skipSpaces(); // content - int oldLen = attributes.getLength(); - + int attrIndex; + if (fBindNamespaces) { + attrIndex = attributes.getLength(); attributes.addAttributeNS(fAttributeQName, XMLSymbols.fCDATASymbol, null); } else { - attributes.addAttribute(fAttributeQName, XMLSymbols.fCDATASymbol, null); + int oldLen = attributes.getLength(); + attrIndex = attributes.addAttribute(fAttributeQName, XMLSymbols.fCDATASymbol, null); // WFC: Unique Att Spec if (oldLen == attributes.getLength()) { @@ -409,11 +411,11 @@ // REVISIT: it seems that this function should not take attributes, and length scanAttributeValue(this.fTempString, fTempString2, fAttributeQName.rawname, attributes, - oldLen, isVC,fCurrentElement.rawname); + attrIndex, isVC,fCurrentElement.rawname); String value = fTempString.toString(); - attributes.setValue(oldLen, value); - attributes.setNonNormalizedValue(oldLen, fTempString2.toString()); - attributes.setSpecified(oldLen, true); + attributes.setValue(attrIndex, value); + attributes.setNonNormalizedValue(attrIndex, fTempString2.toString()); + attributes.setSpecified(attrIndex, true); // record namespace declarations if any. if (fBindNamespaces) { @@ -479,13 +481,13 @@ // declare prefix in context fNamespaceContext.declarePrefix(prefix, uri.length() != 0 ? uri : null); // bind namespace attribute to a namespace - attributes.setURI(oldLen, fNamespaceContext.getURI(XMLSymbols.PREFIX_XMLNS)); + attributes.setURI(attrIndex, fNamespaceContext.getURI(XMLSymbols.PREFIX_XMLNS)); } else { // attempt to bind attribute if (fAttributeQName.prefix != null) { - attributes.setURI(oldLen, fNamespaceContext.getURI(fAttributeQName.prefix)); + attributes.setURI(attrIndex, fNamespaceContext.getURI(fAttributeQName.prefix)); } } } 1.38 +6 -6 xml-xerces/java/src/org/apache/xerces/impl/XMLDocumentFragmentScannerImpl.java Index: XMLDocumentFragmentScannerImpl.java =================================================================== RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/XMLDocumentFragmentScannerImpl.java,v retrieving revision 1.37 retrieving revision 1.38 diff -u -r1.37 -r1.38 --- XMLDocumentFragmentScannerImpl.java 17 Oct 2003 17:34:30 -0000 1.37 +++ XMLDocumentFragmentScannerImpl.java 22 Oct 2003 18:33:43 -0000 1.38 @@ -853,7 +853,7 @@ // content int oldLen = attributes.getLength(); - attributes.addAttribute(fAttributeQName, XMLSymbols.fCDATASymbol, null); + int attrIndex = attributes.addAttribute(fAttributeQName, XMLSymbols.fCDATASymbol, null); // WFC: Unique Att Spec if (oldLen == attributes.getLength()) { @@ -865,10 +865,10 @@ boolean isVC = fHasExternalDTD && !fStandalone; scanAttributeValue(fTempString, fTempString2, fAttributeQName.rawname, attributes, - oldLen, isVC,fCurrentElement.rawname); - attributes.setValue(oldLen, fTempString.toString()); - attributes.setNonNormalizedValue(oldLen, fTempString2.toString()); - attributes.setSpecified(oldLen, true); + attrIndex, isVC,fCurrentElement.rawname); + attributes.setValue(attrIndex, fTempString.toString()); + attributes.setNonNormalizedValue(attrIndex, fTempString2.toString()); + attributes.setSpecified(attrIndex, true); if (DEBUG_CONTENT_SCANNING) System.out.println("<<< scanAttribute()"); } // scanAttribute(XMLAttributes)
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]