diff options
author | PJ Fanning <fanningpj@apache.org> | 2017-07-09 22:32:27 +0000 |
---|---|---|
committer | PJ Fanning <fanningpj@apache.org> | 2017-07-09 22:32:27 +0000 |
commit | 879a6d20c35a5763ea699d09a8e46e3ad0798168 (patch) | |
tree | 3063d4290f210e313a75bb88f560e73408e3d122 /src/java/org/apache | |
parent | 6a4ffa5d6d7c330f87c5fe09affe58d9551191e7 (diff) | |
download | poi-879a6d20c35a5763ea699d09a8e46e3ad0798168.tar.gz poi-879a6d20c35a5763ea699d09a8e46e3ad0798168.zip |
[Bug-61268] avoid NegativeArraySizeException parsing doc file
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1801395 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache')
-rw-r--r-- | src/java/org/apache/poi/ddf/UnknownEscherRecord.java | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/java/org/apache/poi/ddf/UnknownEscherRecord.java b/src/java/org/apache/poi/ddf/UnknownEscherRecord.java index d49176d2bd..55689e2a42 100644 --- a/src/java/org/apache/poi/ddf/UnknownEscherRecord.java +++ b/src/java/org/apache/poi/ddf/UnknownEscherRecord.java @@ -55,8 +55,7 @@ public final class UnknownEscherRecord extends EscherRecord implements Cloneable thedata = new byte[0]; offset += 8; bytesWritten += 8; - while ( bytesRemaining > 0 ) - { + while ( bytesRemaining > 0 ) { EscherRecord child = recordFactory.createRecord( data, offset ); int childBytesWritten = child.fillFields( data, offset, recordFactory ); bytesWritten += childBytesWritten; @@ -67,6 +66,10 @@ public final class UnknownEscherRecord extends EscherRecord implements Cloneable return bytesWritten; } + if (bytesRemaining < 0) { + bytesRemaining = 0; + } + thedata = new byte[bytesRemaining]; System.arraycopy( data, offset + 8, thedata, 0, bytesRemaining ); return bytesRemaining + 8; |