Bug 55490 - OLE2 gets corrupted using BlockSize != 512
Summary: OLE2 gets corrupted using BlockSize != 512
Alias: None
Product: POI
Classification: Unclassified
Component: POIFS (show other bugs)
Version: 3.10-dev
Hardware: PC All
: P2 critical (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2013-08-27 19:57 UTC by sebastian
Modified: 2015-03-22 21:52 UTC (History)
1 user (show)

Simple empty MSI file with BigBlocks (32.00 KB, application/octet-stream)
2013-08-27 19:57 UTC, sebastian
Minimal WIX configuration to create the MSI file (718 bytes, application/octet-stream)
2013-08-27 19:58 UTC, sebastian

Note You need to log in before you can comment on or make changes to this bug.
Description sebastian 2013-08-27 19:57:40 UTC
Created attachment 30769 [details]
Simple empty MSI file with BigBlocks

We are developing a MSI reader/writer based upon POIFS. Using a x64 Windows 7 and WIX we create MSI files that can not be modified by POIFS.

The file can be created by using:
  candle.exe minimal.wxs -o tmp.wixobj
  light tmp.wixobj -pdbout tmp.wixpdb -o empty.msi

The resulting MSI is attached to this bug report. The testcase to create a corrupt OLE2 document is rather simple:

FileInputStream  istream = new FileInputStream("empty.msi");
FileOutputStream ostream = new FileOutputStream("empty2.msi");

new POIFSFileSystem(istream).writeFilesystem(ostream);

We suspect that BigBlocks are the critical part.
Thanks in advance!
Comment 1 sebastian 2013-08-27 19:58:53 UTC
Created attachment 30770 [details]
Minimal WIX configuration to create the MSI file
Comment 2 Nick Burch 2013-08-27 22:01:58 UTC
POIFS has some limited support for non-512 blocks, but it's not ideal, and not really fixable. The POIFSFileSystem code has some assumptions backed in very deeply, which are almost but not always correct...

NPOIFS should work fine with both 512 and 4k blocks. The various problems spotted with POIFSFileSystem have been fixed in NPOIFSFileSystem

However... NPOIFSFileSystem doesn't quite have write support. It's almost all there, but there's one or two failing unit tests to fix. I've been meaning to go back to it to finish it, but that has been the case for 2 or 3 years now :/

If you have a bit of time, I'd suggest you switch to NPOIFS, and give a hand to squash those last few bugs!
Comment 3 sebastian 2013-08-28 08:26:46 UTC
That did the trick! Thank you very much, I'll verify that everything is working as expected and report back.
Comment 4 Dominik Stadler 2015-03-22 21:52:36 UTC
Seems to basically work with using NPOIFSFileSystem, additional bugs should probably be handled in separate bug entries.