]> source.dussan.org Git - poi.git/commitdiff
Provide better exception if we would access out of bounds in arraycopy for Escher...
authorDominik Stadler <centic@apache.org>
Mon, 11 May 2015 20:00:42 +0000 (20:00 +0000)
committerDominik Stadler <centic@apache.org>
Mon, 11 May 2015 20:00:42 +0000 (20:00 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1678812 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/ddf/EscherPropertyFactory.java

index 3dcce79b86f0000a0edc8fb4e8516813eac05c39..3e653f5b8dbb4f111eff8c508075a03c9b64ae5d 100644 (file)
@@ -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;
                 }
             }