additional safety belts to handle broken files

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1187647 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Sergey Vladimirov 2011-10-22 02:52:52 +00:00
parent 8f2c24795c
commit a3075cd7dc
1 changed files with 8 additions and 4 deletions

View File

@ -158,11 +158,15 @@ public class VariantSupport extends Variant
TypedPropertyValue typedPropertyValue = new TypedPropertyValue(
(int) type, null );
int unpadded;
try {
try
{
unpadded = typedPropertyValue.readValue( src, offset );
} catch (UnsupportedOperationException exc) {
final byte[] v = new byte[length];
System.arraycopy( src, offset, v, 0, length );
}
catch ( UnsupportedOperationException exc )
{
int propLength = Math.min( length, src.length - offset );
final byte[] v = new byte[propLength];
System.arraycopy( src, offset, v, 0, propLength );
throw new ReadingNotSupportedException( type, v );
}