Bug 51945

Summary: [BUG] StyleSheet getCharacterStyle ArrayIndex OOB - Negative style number
Product: POI Reporter: Jeremy <rpi_alum>
Component: HWPFAssignee: POI Developers List <dev>
Severity: normal    
Priority: P2    
Version: 3.8-dev   
Target Milestone: ---   
Hardware: PC   
OS: All   

Description Jeremy 2011-10-04 00:08:08 UTC
Unable to include sample document due to sensitive nature.

Somehow one of my documents is ending up with a negative style index.  File opens successfully in Word 2010, and appears to be a Wrod97-2003 document.

I tried adding an OR check with the greater than length to return NULL values when the index was less than zero. But it would then fail on the getStyleDescription() call.

if ( styleIndex >= _styleDescriptions.length || styleIndex  < 0)
   return NIL_CHP;

Stack Trace (Daily Build):
Caused by: java.lang.ArrayIndexOutOfBoundsException: -2560
	at org.apache.poi.hwpf.model.StyleSheet.getCharacterStyle(StyleSheet.java:325)
	at org.apache.poi.hwpf.model.CHPX.getCharacterProperties(CHPX.java:74)
	at org.apache.poi.hwpf.usermodel.CharacterRun.<init>(CharacterRun.java:98)
	at org.apache.poi.hwpf.usermodel.Range.getCharacterRun(Range.java:853)
	at org.apache.poi.hwpf.model.PicturesTable.getAllPictures(PicturesTable.java:208)
	at org.apache.tika.parser.microsoft.WordExtractor$PicturesSource.<init>(WordExtractor.java:502)
	at org.apache.tika.parser.microsoft.WordExtractor$PicturesSource.<init>(WordExtractor.java:492)
	at org.apache.tika.parser.microsoft.WordExtractor.parse(WordExtractor.java:81)
	at org.apache.tika.parser.microsoft.OfficeParser.parse(OfficeParser.java:200)
	at org.apache.tika.
Comment 1 Sergey Vladimirov 2012-11-06 16:33:03 UTC

Does file passes binary format validation?

See here for details: 
Comment 2 Dominik Stadler 2016-02-14 18:52:02 UTC
No update for a long time, therefore I am closing this, please reopen with more information if this is still a problem for you.