From: Sergey Vladimirov Date: Tue, 5 Jul 2011 03:02:12 +0000 (+0000) Subject: add additional sanity checks X-Git-Tag: REL_3_8_BETA4~320 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=8567b6985868c27f43d65414b26992fceb4f2695;p=poi.git add additional sanity checks git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1142880 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/BytePropertyNode.java b/src/scratchpad/src/org/apache/poi/hwpf/model/BytePropertyNode.java index 4ceb2d1d8d..59ac18e7b1 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/model/BytePropertyNode.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/model/BytePropertyNode.java @@ -38,6 +38,11 @@ public abstract class BytePropertyNode extends PropertyNode { translator.getCharIndex(fcEnd, translator.getCharIndex(fcStart)), buf ); + + if ( fcStart > fcEnd ) + throw new IllegalArgumentException( "fcStart (" + fcStart + + ") > fcEnd (" + fcEnd + ")" ); + this.startBytes = fcStart; this.endBytes = fcEnd; } diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/PropertyNode.java b/src/scratchpad/src/org/apache/poi/hwpf/model/PropertyNode.java index e3338fd610..6c5a23972a 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/model/PropertyNode.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/model/PropertyNode.java @@ -56,6 +56,10 @@ public abstract class PropertyNode implements Comparable, Cloneable _logger.log(POILogger.WARN, "A property claimed to start before zero, at " + _cpStart + "! Resetting it to zero, and hoping for the best"); _cpStart = 0; } + + if ( fcStart > fcEnd ) + throw new IllegalArgumentException( "fcStart (" + fcStart + + ") > fcEnd (" + fcEnd + ")" ); } /**