Author: nick
Date: Wed May 29 17:31:50 2013
New Revision: 1487558
URL: http://svn.apache.org/r1487558
Log:
More on bug #54682 - check for the end offset overflowing too
Modified:
poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/UnhandledDataStructure.java
Modified:
poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/UnhandledDataStructure.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/UnhandledDataStructure.java?rev=1487558&r1=1487557&r2=1487558&view=diff
==============================================================================
---
poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/UnhandledDataStructure.java
(original)
+++
poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/UnhandledDataStructure.java
Wed May 29 17:31:50 2013
@@ -34,10 +34,12 @@ public final class UnhandledDataStructur
public UnhandledDataStructure(byte[] buf, int offset, int length)
{
// Sanity check the size they've asked for
- if (offset + length > buf.length)
+ int offsetEnd = offset + length;
+ if (offsetEnd > buf.length || offsetEnd < 0)
{
throw new IndexOutOfBoundsException("Buffer Length is " + buf.length + "
" +
- "but code is tried to read " +
length + " from offset " + offset);
+ "but code is tried to read " +
length + " " +
+ "from offset " + offset + " to " +
offsetEnd);
}
if (offset < 0 || length < 0)
{
@@ -46,7 +48,7 @@ public final class UnhandledDataStructur
}
// Save that requested portion of the data
- _buf = Arrays.copyOfRange(buf, offset, offset + length);
+ _buf = Arrays.copyOfRange(buf, offset, offsetEnd);
}
byte[] getBuf()
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]