summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDominik Stadler <centic@apache.org>2015-05-11 20:00:42 +0000
committerDominik Stadler <centic@apache.org>2015-05-11 20:00:42 +0000
commit51acceca4808afbbee8f987b6dd41e370381eb1a (patch)
treef3f2178836e18b003ea6f7fc1c2a0ed3723f8ae7 /src
parent43710ae5f2895a268437520ed76ff1c293e452b3 (diff)
downloadpoi-51acceca4808afbbee8f987b6dd41e370381eb1a.tar.gz
poi-51acceca4808afbbee8f987b6dd41e370381eb1a.zip
Provide better exception if we would access out of bounds in arraycopy for Escher properties
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1678812 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/java/org/apache/poi/ddf/EscherPropertyFactory.java9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/java/org/apache/poi/ddf/EscherPropertyFactory.java b/src/java/org/apache/poi/ddf/EscherPropertyFactory.java
index 3dcce79b86..3e653f5b8d 100644
--- a/src/java/org/apache/poi/ddf/EscherPropertyFactory.java
+++ b/src/java/org/apache/poi/ddf/EscherPropertyFactory.java
@@ -82,7 +82,14 @@ public final class EscherPropertyFactory {
pos += ((EscherArrayProperty)p).setArrayData(data, pos);
} else {
byte[] complexData = ((EscherComplexProperty)p).getComplexData();
- System.arraycopy(data, pos, complexData, 0, complexData.length);
+
+ int leftover = data.length-pos;
+ if(leftover < complexData.length){
+ throw new IllegalStateException("Could not read complex escher property, lenght was " + complexData.length + ", but had only " +
+ leftover + " bytes left");
+ }
+
+ System.arraycopy(data, pos, complexData, 0, complexData.length);
pos += complexData.length;
}
}