Bug 31821 - [INFO NEEDED] EscherArrayProperty class throws ArayIndexoutofbounds exception.
Summary: [INFO NEEDED] EscherArrayProperty class throws ArayIndexoutofbounds exception.
Status: RESOLVED INVALID
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 2.5-FINAL
Hardware: Other Windows XP
: P3 critical (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-10-21 06:29 UTC by as
Modified: 2009-02-18 09:40 UTC (History)
0 users



Attachments
fixes ArrayOutOfBounds exception (532 bytes, patch)
2007-02-08 08:49 UTC, Brian Kalbfus
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description as 2004-10-21 06:29:45 UTC
I am getting a exception when i am trying to biff view xls  file.

java.lang.ArrayIndexOutOfBoundsException
        at java.lang.System.arraycopy(Native Method)
        at org.apache.poi.ddf.EscherArrayProperty.getElement
(EscherArrayProperty
.java:111)
        at org.apache.poi.ddf.EscherArrayProperty.toString
(EscherArrayProperty.j
ava:146)
        at org.apache.poi.ddf.EscherOptRecord.toString
(EscherOptRecord.java:138)

        at org.apache.poi.ddf.EscherContainerRecord.toString
(EscherContainerReco
rd.java:158)
        at org.apache.poi.hssf.record.AbstractEscherHolderRecord.toString
(Abstra
ctEscherHolderRecord.java:126)
        at org.apache.poi.hssf.dev.BiffViewer.dumpNormal(BiffViewer.java:148)
        at org.apache.poi.hssf.dev.BiffViewer.access$1(BiffViewer.java:144)
        at org.apache.poi.hssf.dev.BiffViewer$RecordDetails.dump
(BiffViewer.java
:700)
        at org.apache.poi.hssf.dev.BiffViewer.createRecords
(BiffViewer.java:120)

        at org.apache.poi.hssf.dev.BiffViewer.run(BiffViewer.java:73)
        at org.apache.poi.hssf.dev.BiffViewer.main(BiffViewer.java:652)



I just debugged a little  and found a strange thing

Here is the modified code i used to debug

    public byte[] getElement( int index )
    {
        int actualSize = getActualSizeOfElements(getSizeOfElements());
        byte[] result = new byte[actualSize];
       try {
			System.arraycopy(complexData, FIXED_SIZE + index * 
actualSize, result, 0, result.length );
			//System.arraycopy(complexData, 0, result, 0, 
result.length );
        } catch (Exception exception) {
        	System.out.println("================");
        	System.out.println("src array total length 
= "+complexData.length);
			//System.out.println("src position = "+FIXED_SIZE + 
index * actualSize);
			System.out.println("FIXED_SIZE  "+FIXED_SIZE);
			System.out.println("index  "+index);
			System.out.println("actualSize  "+actualSize);
			System.out.println("dest array len = "+result.length);
			
			System.out.println("length = "+result.length);
			
			System.out.println("=================");
        }

The results are surprising..
here are they

src array total length = 6
FIXED_SIZE  6
index  7
actualSize  1290
dest array len = 1290
length = 1290
=================
================
src array total length = 6
FIXED_SIZE  6
index  8
actualSize  1290
dest array len = 1290
length = 1290
=================
================
src array total length = 6
FIXED_SIZE  6
index  9
actualSize  1290
dest array len = 1290
length = 1290
=================
================
src array total length = 6
FIXED_SIZE  6
index  10
actualSize  1290
dest array len = 1290
length = 1290
=================
================
src array total length = 6
FIXED_SIZE  6
index  11
actualSize  1290
dest array len = 1290
length = 1290
=================
================
src array total length = 6
FIXED_SIZE  6
index  12
actualSize  1290
dest array len = 1290
length = 1290
=================

So is the logic 

System.arraycopy(complexData, FIXED_SIZE + index * actualSize, result, 0, 
result.length );
 correct??
Comment 1 Jason Height 2004-10-25 01:14:26 UTC
I know that this is critical for you, however i am affraid that you will have to
bear with us.

I certainly work on HSSF for fun ... (now thats an oxymoron) ... and only really
get about an hour a day to do so. I dont know about whether any other developer
has time.

However i prefer to work on those issues that result in corruption, rather than
feature requests, so this one is high on my radar.

Unfortunately for you i am currently rewriting some of the low level record
reading code which i havent quite got into a usable state hence i cant work on
your probalem ... yet.

Jason
Comment 2 Glen Stampoultzis 2004-10-25 10:55:21 UTC
You can turn off deserializing of the escher records.

Go to line 632 and alter:

System.setProperty("poi.deserialize.escher", "true");

to

System.setProperty("poi.deserialize.escher", "false");
Comment 3 Glen Stampoultzis 2004-10-25 11:01:25 UTC
Actually...  not exactly right.  Remove the line completely to turn off
deserialization of escher records.
Comment 4 Avik Sengupta 2005-05-03 15:37:08 UTC
Can you attach the excel sheet that was causing problems for you? There have
been some fixes to these parts, so maybe this has also been fixed?
Comment 5 Brian Kalbfus 2007-02-08 08:49:13 UTC
Created attachment 19549 [details]
fixes ArrayOutOfBounds exception

In trying various things, I got this common error, found the code, and fixed
it.
Comment 6 Yegor Kozlov 2008-05-17 06:46:19 UTC
Please check if the problem still exists in 3.1-beta1.

Yegor
Comment 7 David Fisher 2009-02-18 09:40:35 UTC
Low Level code is clearly different.