Details
-
Bug
-
Status: Resolved
-
Critical
-
Resolution: Invalid
-
None
-
None
-
None
Description
The fix revision 318723 was aimed to remove an NPE bug on the "fEnumeration" in the method "getLexicalEnumerations" of the file "/xerces/java/trunk/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java" , but it is incomplete.
Since the "fEnumeration" is an class field and also could be null during the run-time execution, it should also be null-checked before being dereferenced in other methods (e.g., Line 1311 in the method "checkFacets").
The buggy code the proposed missing fixes should be made in is copied as bellowing:
private void checkFacets(ValidatedInfo validatedInfo) throws InvalidDatatypeValueException {
Object ob = validatedInfo.actualValue;
String content = validatedInfo.normalizedValue;
int length = fDVs[fValidationDV].getDataLength(ob);
// maxLength
if ( (fFacetsDefined & FACET_MAXLENGTH) != 0 ) {
if ( length > fMaxLength ) {
throw new InvalidDatatypeValueException("cvc-maxLength-valid",
new Object[]
);
}
}
//minLength
if ( (fFacetsDefined & FACET_MINLENGTH) != 0 ) {
if ( length < fMinLength ) {
throw new InvalidDatatypeValueException("cvc-minLength-valid",
new Object[]
);
}
}
//length
if ( (fFacetsDefined & FACET_LENGTH) != 0 ) {
if ( length != fLength ) {
throw new InvalidDatatypeValueException("cvc-length-valid",
new Object[]
);
}
}
//enumeration
if ( ((fFacetsDefined & FACET_ENUMERATION) != 0 ) ) {
boolean present = false;
[Line 1311] for (int i = 0; i < fEnumeration.size(); i++) {
[Line 1312] if (isEqual(ob, fEnumeration.elementAt))
}
if(!present){
throw new InvalidDatatypeValueException("cvc-enumeration-valid",
new Object []
);
}
}
//fractionDigits
if ((fFacetsDefined & FACET_FRACTIONDIGITS) != 0) {
int scale = fDVs[fValidationDV].getFractionDigits(ob);
if (scale > fFractionDigits) {
throw new InvalidDatatypeValueException("cvc-fractionDigits-valid",
new Object[]
);
}
}
//totalDigits
if ((fFacetsDefined & FACET_TOTALDIGITS)!=0) {
int totalDigits = fDVs[fValidationDV].getTotalDigits(ob);
if (totalDigits > fTotalDigits) {
throw new InvalidDatatypeValueException("cvc-totalDigits-valid",
new Object[]
);
}
}
int compare;
//maxinclusive
if ( (fFacetsDefined & FACET_MAXINCLUSIVE) != 0 ) {
compare = fDVs[fValidationDV].compare(ob, fMaxInclusive);
if (compare != -1 && compare != 0) {
throw new InvalidDatatypeValueException("cvc-maxInclusive-valid",
new Object[]
);
}
}
//maxExclusive
if ( (fFacetsDefined & FACET_MAXEXCLUSIVE) != 0 ) {
compare = fDVs[fValidationDV].compare(ob, fMaxExclusive );
if (compare != -1) {
throw new InvalidDatatypeValueException("cvc-maxExclusive-valid",
new Object[]
);
}
}
//minInclusive
if ( (fFacetsDefined & FACET_MININCLUSIVE) != 0 ) {
compare = fDVs[fValidationDV].compare(ob, fMinInclusive);
if (compare != 1 && compare != 0) {
throw new InvalidDatatypeValueException("cvc-minInclusive-valid",
new Object[]
);
}
}
//minExclusive
if ( (fFacetsDefined & FACET_MINEXCLUSIVE) != 0 ) {
compare = fDVs[fValidationDV].compare(ob, fMinExclusive);
if (compare != 1) {
throw new InvalidDatatypeValueException("cvc-minExclusive-valid",
new Object[]
);
}
}
}