From 8567b6985868c27f43d65414b26992fceb4f2695 Mon Sep 17 00:00:00 2001 From: Sergey Vladimirov Date: Tue, 5 Jul 2011 03:02:12 +0000 Subject: [PATCH] add additional sanity checks git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1142880 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/org/apache/poi/hwpf/model/BytePropertyNode.java | 5 +++++ .../src/org/apache/poi/hwpf/model/PropertyNode.java | 4 ++++ 2 files changed, 9 insertions(+) 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 + ")" ); } /** -- 2.39.5