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
This commit is contained in:
Dominik Stadler 2015-05-11 20:00:42 +00:00
parent 43710ae5f2
commit 51acceca48
1 changed files with 8 additions and 1 deletions

View File

@ -82,7 +82,14 @@ public final class EscherPropertyFactory {
pos += ((EscherArrayProperty)p).setArrayData(data, pos); pos += ((EscherArrayProperty)p).setArrayData(data, pos);
} else { } else {
byte[] complexData = ((EscherComplexProperty)p).getComplexData(); 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; pos += complexData.length;
} }
} }