Bug 52035

Summary: Large MS Word 6.0 Word Document java.lang.ArrayIndexOutOfBoundsException: -283137
Product: POI Reporter: Kim Ebert <kim.ebert>
Component: HWPFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: major CC: tim.barrett
Priority: P2    
Version: 3.7-FINAL   
Target Milestone: ---   
Hardware: PC   
OS: Linux   

Description Kim Ebert 2011-10-14 23:50:25 UTC
Word6.0 file with 32MB size

It appears that it should be unsigned instead of signed. This patch appears to fix the problem on read. I checked and it appears to still be a problem against poi-3.8-beta4.


diff -uNr ../old/poi-3.7/src/scratchpad/src/org/apache/poi/hwpf/model/OldCHPBinTable.java ./src/scratchpad/src/org/apache/poi/hwpf/model/OldCHPBinTable.java
--- ../old/poi-3.7/src/scratchpad/src/org/apache/poi/hwpf/model/OldCHPBinTable.java 2010-10-14 04:50:23.000000000 -0600
+++ ./src/scratchpad/src/org/apache/poi/hwpf/model/OldCHPBinTable.java 2011-10-14 17:16:45.414557055 -0600
@@ -49,7 +49,7 @@
{
GenericPropertyNode node = binTable.getProperty(x);

- int pageNum = LittleEndian.getShort(node.getBytes());
+ int pageNum = LittleEndian.getUShort(node.getBytes());
int pageOffset = POIFSConstants.SMALLER_BIG_BLOCK_SIZE * pageNum;

CHPFormattedDiskPage cfkp = new CHPFormattedDiskPage(documentStream,
diff -uNr ../old/poi-3.7/src/scratchpad/src/org/apache/poi/hwpf/model/OldPAPBinTable.java ./src/scratchpad/src/org/apache/poi/hwpf/model/OldPAPBinTable.java
--- ../old/poi-3.7/src/scratchpad/src/org/apache/poi/hwpf/model/OldPAPBinTable.java 2010-10-14 04:50:23.000000000 -0600
+++ ./src/scratchpad/src/org/apache/poi/hwpf/model/OldPAPBinTable.java 2011-10-14 17:18:00.047660407 -0600
@@ -40,7 +40,7 @@
{
GenericPropertyNode node = binTable.getProperty(x);

- int pageNum = LittleEndian.getShort(node.getBytes());
+ int pageNum = LittleEndian.getUShort(node.getBytes());
int pageOffset = POIFSConstants.SMALLER_BIG_BLOCK_SIZE * pageNum;

PAPFormattedDiskPage pfkp = new PAPFormattedDiskPage(documentStream,
Comment 1 Nick Burch 2011-10-15 12:24:13 UTC
Thanks, patch applied in r1183629.