Re: [Bug 35527] - ArrayIndexOutOfBoundsException when reading xls file

2005-07-08 Thread Avik Sengupta
Thanks Amol, this was a long standing bug. 

Does you fix handle writing out as well? Sorry, too lazy to read the
code! :)

On Fri, 2005-07-08 at 16:59 +0200, [EMAIL PROTECTED] wrote:
> DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
> RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
> .
> ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
> INSERTED IN THE BUG DATABASE.
> 
> http://issues.apache.org/bugzilla/show_bug.cgi?id=35527
> 
> 
> [EMAIL PROTECTED] changed:
> 
>What|Removed |Added
> 
>  Status|NEW |RESOLVED
>  Resolution||FIXED
> 
> 
> 
> 
> --- Additional Comments From [EMAIL PROTECTED]  2005-07-08 16:59 ---
> *** I thought i had resolved this issue as fixed  *** 
> *** couple of days back, but my fix comments dont *** 
> *** appear, so I'm adding these comments again***
> 
> 
> Further "investigation" revealed that the byte array
> was falling short 2 bytes when the sid of the SubRecord
> indicated an EndSubRecord.
> 
> Hence,
> I made a slight modification in the change I proposed
> earlier in the file I committed. Here is the changed part:
> 
> 
> 
> while (pos - offset <= size-2) // atleast one "short" must be present
> {
>   short subRecordSid = LittleEndian.getShort(data, pos);
>   short subRecordSize = -1; // set default to "< 0"
>   if (pos-offset <= size-4) { // see if size info is present, else default to 
> -1
> subRecordSize = LittleEndian.getShort(data, pos + 2);
>   }
> 
> 
> 
> 
> 
> Now, when the byte array falls short two bytes when dealing with
> EndSubRecord, the length is implicitly set to 0 since the change
> in ObjRecord now sets the length to default value of -1 if the 
> short value for the SubRecord size is not found.
> 
> 
-- 


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List:http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta POI Project: http://jakarta.apache.org/poi/



DO NOT REPLY [Bug 35527] - ArrayIndexOutOfBoundsException when reading xls file

2005-06-28 Thread bugzilla
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=35527





--- Additional Comments From [EMAIL PROTECTED]  2005-06-28 22:34 ---
Created an attachment (id=15546)
 --> (http://issues.apache.org/bugzilla/attachment.cgi?id=15546&action=view)
"Reduced" file that still generates the error.


-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug, or are watching the assignee.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List:http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta POI Project: http://jakarta.apache.org/poi/



DO NOT REPLY [Bug 35527] - ArrayIndexOutOfBoundsException when reading xls file

2005-06-28 Thread bugzilla
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=35527





--- Additional Comments From [EMAIL PROTECTED]  2005-06-28 23:23 ---
I confirmed the bug with latest on CVS. Here is relevant part of the stack trace
for reference:


java.lang.ArrayIndexOutOfBoundsException: 33
at org.apache.poi.util.LittleEndian.getNumber(LittleEndian.java:491)
at org.apache.poi.util.LittleEndian.getShort(LittleEndian.java:52)
at org.apache.poi.hssf.record.ObjRecord.fillFields(ObjRecord.java:99)
at org.apache.poi.hssf.record.Record.fillFields(Record.java:90)
at org.apache.poi.hssf.record.Record.(Record.java:55)
at org.apache.poi.hssf.record.ObjRecord.(ObjRecord.java:61)


Apparently, org.apache.poi.hssf.record.ObjRecord.fillFields runs out of data in
the loop:

while (pos - offset < size)
{
short subRecordSid = LittleEndian.getShort(data, pos);
short subRecordSize = LittleEndian.getShort(data, pos + 2);
Record subRecord = SubRecord.createSubRecord(subRecordSid,
subRecordSize, data, pos + 4);
subrecords.add(subRecord);
pos += subRecord.getRecordSize();
}

The following fix seemed to work, although the underlying cause is still not 
known:

file: org/apache/poi/hssf/record/ObjRecord.java

  // size-4: since at least the first two shorts have to be read
  while (pos - offset < size-4) 

I was able to read and save the file as a new xls with the above change and the
new file opened up fine.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug, or are watching the assignee.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List:http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta POI Project: http://jakarta.apache.org/poi/



DO NOT REPLY [Bug 35527] - ArrayIndexOutOfBoundsException when reading xls file

2005-07-05 Thread bugzilla
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=35527





--- Additional Comments From [EMAIL PROTECTED]  2005-07-05 14:33 ---
Amol, 

Can you pls check if your check also solves bug 34575. I think they are the 
same. 

I can figure.. does your patch optionally read in the bytes if they exist? coz i
dont think the bug is prevalant in all files with OBJ record. If that is the
case, I think this can go in (..with some comments in code :)

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug, or are watching the assignee.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List:http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta POI Project: http://jakarta.apache.org/poi/



DO NOT REPLY [Bug 35527] - ArrayIndexOutOfBoundsException when reading xls file

2005-07-08 Thread bugzilla
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=35527


[EMAIL PROTECTED] changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||FIXED




--- Additional Comments From [EMAIL PROTECTED]  2005-07-08 16:59 ---
*** I thought i had resolved this issue as fixed  *** 
*** couple of days back, but my fix comments dont *** 
*** appear, so I'm adding these comments again***


Further "investigation" revealed that the byte array
was falling short 2 bytes when the sid of the SubRecord
indicated an EndSubRecord.

Hence,
I made a slight modification in the change I proposed
earlier in the file I committed. Here is the changed part:



while (pos - offset <= size-2) // atleast one "short" must be present
{
  short subRecordSid = LittleEndian.getShort(data, pos);
  short subRecordSize = -1; // set default to "< 0"
  if (pos-offset <= size-4) { // see if size info is present, else default to -1
subRecordSize = LittleEndian.getShort(data, pos + 2);
  }





Now, when the byte array falls short two bytes when dealing with
EndSubRecord, the length is implicitly set to 0 since the change
in ObjRecord now sets the length to default value of -1 if the 
short value for the SubRecord size is not found.


-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug, or are watching the assignee.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List:http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta POI Project: http://jakarta.apache.org/poi/



DO NOT REPLY [Bug 35527] - ArrayIndexOutOfBoundsException when reading xls file

2005-07-08 Thread bugzilla
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=35527


[EMAIL PROTECTED] changed:

   What|Removed |Added

 CC||[EMAIL PROTECTED]




--- Additional Comments From [EMAIL PROTECTED]  2005-07-08 17:02 ---
*** Bug 34575 has been marked as a duplicate of this bug. ***

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug, or are watching the assignee.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List:http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta POI Project: http://jakarta.apache.org/poi/