https://issues.apache.org/bugzilla/show_bug.cgi?id=52446
Bug #: 52446
Summary: BufferUnderlowException in NPropertyTable
Product: POI
Version: 3.8-dev
Platform: PC
Status: NEW
Severity: normal
Priority: P2
Component: POIFS
AssignedTo: [email protected]
ReportedBy: [email protected]
Classification: Unclassified
Created attachment 28131
--> https://issues.apache.org/bugzilla/attachment.cgi?id=28131
The patch with my workaround
I have a .doc file which is OK from the MSOffice POV
java.nio.BufferUnderflowException
at java.nio.HeapByteBuffer.get(HeapByteBuffer.java:127)
at
org.apache.poi.poifs.property.NPropertyTable.buildProperties(NPropertyTable.java:93)
at org.apache.poi.poifs.property.NPropertyTable.<init>(NPropertyTable.java:62)
at
org.apache.poi.poifs.filesystem.NPOIFSFileSystem.readCoreContents(NPOIFSFileSystem.java:379)
at
org.apache.poi.poifs.filesystem.NPOIFSFileSystem.<init>(NPOIFSFileSystem.java:293)
The BFFValidator returns
<BFFValidation
path="twenty-tips.doc"
datetime="01/10/12 16:07:25"
result="ERROR 0x80030109. Docfile zostal uszkodzony. "
reason="The Microsoft Office Binary File Format Validator encountered an
error reading the file you specified.">
</BFFValidation>
In English it's "Docfile has been corrupted".
I came up with a workaround. In NPropertyTable.buildProperties, instead of
data = new byte[bigBlockSize.getBigBlockSize()];
I would put:
int dataSize = bigBlockSize.getBigBlockSize() <= bb.remaining() ?
bigBlockSize.getBigBlockSize() : bb.remaining();
data = new byte[dataSize];
So get the big block size only if it's less than or equal to the number of
remaining bytes. Otherwise, just get the remaining bytes.
The file is obviously corrupted, yet it opens up just fine in Word and I can
get fulltext and metadata with the old POIFSFileSystem. This problem popped up
in my regression tests, when I switched to NPOIFSFileSystem. It seems like a
safe workaround to me. For correct files, it won't change anything, for other
corrupted files it will probably move the error to somewhere within
PropertyFactory.convertToProperties. For my file, it's the difference between
life and death.
Unfortunately I can't share the file.
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]