Bug 35486

Summary: File with size different of modulos 512 or 0x200
Product: POI Reporter: Christophe DUPUIS <c.dupuis>
Component: POIFSAssignee: POI Developers List <dev>
Status: RESOLVED WONTFIX    
Severity: normal    
Priority: P2    
Version: 2.5-FINAL   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   

Description Christophe DUPUIS 2005-06-23 17:51:25 UTC
When opening a file with POIFSFileSystem fs = new POIFSFileSystem(fis);
if this file have a size not modulus 0x200 then an exception occured.

It's seem that old Ole Document can have this size for example : 539 990 bytes
(0x83D56).

If the file is re save with new softwar, then the size is : 603 136 bytes (0x93400)

I have done a patch in RawDataBlock
        _data = new byte[ POIFSConstants.BIG_BLOCK_SIZE ];
        int count = IOUtils.readFully(stream, _data);

        if (count == -1)
        {
            _eof = true;
        }
        else if (count != POIFSConstants.BIG_BLOCK_SIZE)
        {
            String type = " byte" + ((count == 1) ? ("")
                                                  : ("s"));
/*
            throw new IOException("Unable to read entire block; " + count
                                  + type + " read; expected "
                                  + POIFSConstants.BIG_BLOCK_SIZE + " bytes");
                                  */
                                 System.err.println("Unable to read entire
block; " + count
                                 + type + " read; expected "
                                 + POIFSConstants.BIG_BLOCK_SIZE + " bytes"
);
        }
        else
        {
            _eof = false;
        }
Comment 1 Marc Johnson 2005-06-27 14:47:17 UTC
I'm thinking this has to be a really old document that doesn't conform to the 
current model for OLE documents. Under the current model, documents have to be 
written in blocks and the block size is a power of 2. The only block size that 
would make sense for the document cited is *2 bytes*, which would be extremely 
inefficient.