Bug 17208 - [PATCH] WordDocument Problem: createListTables - Negative Array Size
Summary: [PATCH] WordDocument Problem: createListTables - Negative Array Size
Status: RESOLVED WONTFIX
Alias: None
Product: POI
Classification: Unclassified
Component: HDF (show other bugs)
Version: 2.0-dev
Hardware: PC All
: P3 blocker (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-02-19 15:57 UTC by Robert Paris
Modified: 2005-03-20 17:06 UTC (History)
0 users



Attachments
Proposed patch (61.92 KB, patch)
2003-03-04 21:47 UTC, bob.otterberg
Details | Diff
[PATCH] A simple test case (new files contained in a .zip) (10.90 KB, application/octet-stream)
2003-03-13 02:28 UTC, bob.otterberg
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Paris 2003-02-19 15:57:19 UTC
I have a word document that was created in word 2000. Whenever I attempt to 
create a WordDocument object, it throws the exception:

Exception in thread "main" java.lang.NegativeArraySizeException
        at org.apache.poi.hdf.extractor.data.ListTables.createLVL
(ListTables.java:206)
        at org.apache.poi.hdf.extractor.data.ListTables.initLFO
(ListTables.java:184)
        at org.apache.poi.hdf.extractor.data.ListTables.<init>
(ListTables.java:78)
        at org.apache.poi.hdf.extractor.WordDocument.createListTables
(WordDocument.java:1670)
        at org.apache.poi.hdf.extractor.WordDocument.findFormatting
(WordDocument.java:399)
        at org.apache.poi.hdf.extractor.WordDocument.processComplexFile
(WordDocument.java:326)
        at org.apache.poi.hdf.extractor.WordDocument.readFIB
(WordDocument.java:278)
        at org.apache.poi.hdf.extractor.WordDocument.<init>
(WordDocument.java:228)
        at Word.main(Word.java:12)

The document has only text, and a footer. Let me know if you need more 
information. I would be happy to work on this problem, but I do not fully 
understand what LittleEndian.getInt is doing, for example. If someone could 
explain to me the purpose of that (and where to get info on that), as well as 
where to get info on Word 2000 document format, I'm sure I can be of help.
Comment 1 Robert Paris 2003-02-22 16:41:03 UTC
I did a bit of research into this problem. From what I can tell, the value (at 
position 24) of cbGrpprlChpx in LVLF is -1 (on the 4th list in my test case). I 
do not know if this is a valid value (is it?), but the code does not handle 
this. So what happens is the code attempts to create: new byte[ -1 ].

To create this exception, I used windows 2000, word 2000 and created a document 
with a numbered list. It only happens with multi-level lists.
Comment 2 bob.otterberg 2003-03-04 21:47:02 UTC
Created attachment 5150 [details]
Proposed patch
Comment 3 bob.otterberg 2003-03-04 21:49:03 UTC
I uploaded a proposed patch for the problem.  I was also experience similar 
problems with a few of my files.  The proposed patch fixed my problem.  I think 
it will fix Robert's also.  Might also fix bug 16305.
Comment 4 bob.otterberg 2003-03-13 02:28:04 UTC
Created attachment 5302 [details]
[PATCH] A simple test case (new files contained in a .zip)
Comment 5 Andy Oliver 2003-03-21 16:57:20 UTC
Note that no one will probably commit anything not labeled with PATCH in the
subject line (because we query on them ;-) )
Comment 6 Avik Sengupta 2003-03-24 21:26:32 UTC
Andy, are you planning on comitting this? I'll do it tomorrow if you havent got
it by then. 
Comment 7 Avik Sengupta 2003-04-02 12:20:32 UTC
guess what? apparently this is the first testcase in hdf!! How do i run
testcases in scratchpad???? does {old|new} cent let me do that??????
Comment 8 Andy Oliver 2003-04-11 02:41:56 UTC
committed.  Nice work.  Please verify.
Comment 9 bob.otterberg 2003-04-15 14:47:31 UTC
There's a problem with the data files used by the test case.  The files 
committed to CVS don't match the files posted in the zip.  Each of the files 
committed to CVS is slightly larger than the corresponding file in the zip.

filename         size in zip     size in CVS
--------------------------------------------
empty.doc        19456           19462
simple.doc       19456           19463
simple-list.doc  19456           19467
simple-table.doc 19456           19467

Notice that the file sizes in the zip are a multiple of 512.  The file sizes in 
CVS are not a multiple of 512.  This presents all sorts of problems with the
RawDataBlock class in org.apache.poi.poifs.storage.
Word 2000 is unable to open any of the files committed to CVS.  No problem with 
the files in the zip.

I downloaded the zip again and verified it.  The files in it are definitely 
OK.  I think you'll need to re-extract the files and re-commit them to CVS.
Comment 10 bob.otterberg 2003-04-28 17:16:38 UTC
I reopened the bug because the Word docs added to CVS for use by the test cases 
are not correct.  Check the comment from 2003-04-15 14:47 for details.  I 
verified that the attached zip file is correct.  The Word docs simply need to 
be extracted and replaced in CVS.
Comment 11 Andy Oliver 2003-07-24 15:46:02 UTC
Should be against HWPF if its still a problem