Bug 57851 - NPE in NPOIFSFileSystem for corrupted MSG file
Summary: NPE in NPOIFSFileSystem for corrupted MSG file
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: POIFS (show other bugs)
Version: 3.11-FINAL
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-04-23 11:28 UTC by Marcin Łoś
Modified: 2015-04-23 18:35 UTC (History)
0 users



Attachments
Problematic file (20.15 KB, application/x-ole-storage)
2015-04-23 11:28 UTC, Marcin Łoś
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Marcin Łoś 2015-04-23 11:28:09 UTC
Created attachment 32682 [details]
Problematic file

Constructor of NPOIFSFileSystem throws NPE when given an input stream to a file created by slightly modifying valid MSG file.

@Test
public void shouldNotThrowNPE() throws IOException {
    InputStream input = ClassLoader.getSystemResourceAsStream("corrupted.msg");
    new NPOIFSFileSystem(input);
}

Resulting stack trace (removed JUnit frames):

java.lang.NullPointerException
	at org.apache.poi.poifs.property.DirectoryProperty.addChild(DirectoryProperty.java:256)
	at org.apache.poi.poifs.property.PropertyTableBase.populatePropertyTree(PropertyTableBase.java:115)
	at org.apache.poi.poifs.property.PropertyTableBase.populatePropertyTree(PropertyTableBase.java:118)
	at org.apache.poi.poifs.property.PropertyTableBase.<init>(PropertyTableBase.java:63)
	at org.apache.poi.poifs.property.NPropertyTable.<init>(NPropertyTable.java:66)
	at org.apache.poi.poifs.filesystem.NPOIFSFileSystem.readCoreContents(NPOIFSFileSystem.java:416)
	at org.apache.poi.poifs.filesystem.NPOIFSFileSystem.<init>(NPOIFSFileSystem.java:324)
	at pl.edu.agh.seeker.extractor.mail.MsgExtractorTest.shouldNotThrowNPE(MsgExtractorTest.java:24)

The culprit seems to be org.apache.poi.poifs.property.PropertyFactory.convertToProperties, which adds null to the list of properties upon encountering unrecognized property type.
Comment 1 Nick Burch 2015-04-23 18:35:55 UTC
Thanks for the investigation and the small test file! Fixed in r1675702.