Bug 51559 - ArrayIndexOutOfBoundsException in 3rd party generated MSG file
Summary: ArrayIndexOutOfBoundsException in 3rd party generated MSG file
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: POIFS (show other bugs)
Version: 3.8-dev
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-26 10:54 UTC by b.geisselmeier
Modified: 2011-07-28 08:13 UTC (History)
0 users



Attachments
files causing the problems (60.00 KB, application/octet-stream)
2011-07-26 10:54 UTC, b.geisselmeier
Details
code snippet to reproduce error (1.69 KB, text/x-java)
2011-07-26 10:56 UTC, b.geisselmeier
Details

Note You need to log in before you can comment on or make changes to this bug.
Description b.geisselmeier 2011-07-26 10:54:16 UTC
Created attachment 27319 [details]
files causing the problems

In our application we process MS Outlook files (msg) with POIFS.

With the file attached I get various exceptions:

poi-3.2-FINAL
{code}
java.io.IOException: Cannot remove block[ 114 ]; out of range[ 0 - 23 ]
      at org.apache.poi.poifs.storage.BlockListImpl.remove(BlockListImpl.java:104)
      at org.apache.poi.poifs.storage.BlockAllocationTableReader.fetchBlocks(BlockAllocationTableReader.java:190)
      at org.apache.poi.poifs.storage.BlockListImpl.fetchBlocks(BlockListImpl.java:130)
      at org.apache.poi.poifs.filesystem.POIFSFileSystem.processProperties(POIFSFileSystem.java:524)
      at org.apache.poi.poifs.filesystem.POIFSFileSystem.<init>(POIFSFileSystem.java:176)
{code}

POI-3.8 beta 3 and SVN trunk (rev. 1151057)
{code}
java.lang.ArrayIndexOutOfBoundsException: 0
	at org.apache.poi.poifs.storage.SmallDocumentBlock.getDataInputBlock(SmallDocumentBlock.java:194)
	at org.apache.poi.poifs.filesystem.POIFSDocument.getDataInputBlock(POIFSDocument.java:282)
	at org.apache.poi.poifs.filesystem.ODocumentInputStream.getDataInputBlock(ODocumentInputStream.java:107)
	at org.apache.poi.poifs.filesystem.ODocumentInputStream.<init>(ODocumentInputStream.java:71)
	at org.apache.poi.poifs.filesystem.DocumentInputStream.<init>(DocumentInputStream.java:60)
{code}

I've also attached a code snippet to reproduce this behaviour.

As this msg file is not produced by Outlook itself but by a 3rd party application, I'm not sure if there is a bug in POIFS or if the file is corrupt.
The producer of this application argues that Outlook can open that file, so "it must be correct".

Do you have a hint for me what might be the problem here or possibly a work around?

Thanks a lot,
Benjamin
Comment 1 b.geisselmeier 2011-07-26 10:56:25 UTC
Created attachment 27320 [details]
code snippet to reproduce error
Comment 2 Nick Burch 2011-07-26 21:15:41 UTC
Any chance you could try with NPOIFSFileSystem from POI 3.8 beta 3? Rather than opening a POIFSFileSystem, open a NPOIFSFileSytem, and pass the root of that to HSMF. There's a fair chance it'll work with the new NPOIFS code where it may have previously failed for POIFS
Comment 3 b.geisselmeier 2011-07-28 08:13:30 UTC
Thank you for this hint. With the _N_POIFSFileSytem this file can be accessed.

So I close this issue now and wait for the final release of POI 3.8

Best Regards,
Benjamin