Bug 30783 - Protected Workbook Read Error
Summary: Protected Workbook Read Error
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 2.5-FINAL
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2004-08-21 03:36 UTC by chang.zhao
Modified: 2004-11-16 19:05 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description chang.zhao 2004-08-21 03:36:32 UTC
Create a new Excel Document, select tools->protect workbook, and type in a 
This will cause

POIFSFileSystem fs = new POIFSFileSystem(i);
HSSFWorkbook wb = new HSSFWorkbook(fs); <=

to fail.

Upon investigation of this bug, it seems that a protected workbook (but not a 
protected sheet) will cause the system to report length inaccurately:

i.e. in FontRecord 
fillFields(byte [] data, short size, int offset)
 field_10_font_name_len      = data[ 14 + offset ];

on an unprotected workbook would give a sane value like 5.  However, on a 
protected workbook it would report a wierd value like 49.  I believe the 
previous bugs with ArrayOutofBoundsException s might be related to this 
incorrect length reporting.  This is not limited to length, other fields are 
going insane as well.

Further, further investigation turns out that protected workbooks have an extra 
record of type 47, length 56 right between BOF and InterfaceHeader, and it 
looks like every record after that record (including the interfaceheader) got 
everything scambled.

On a related note,  as I was looking at FontRecord.java, in 
fillFields(byte [] data, short size, int offset)

if (data[ 15 ] == 0) {   // is compressed unicode
    field_11_font_name = StringUtil.getFromCompressedUnicode(data, 16,

should perhaps be
if (data[ 15 + offset] == 0) {
    field_11_font_name = StringUtil.getFromCompressedUnicode(data, 16 + offset,


?  Or is there any reason that offset shouldn't be added?


Comment 1 Glen Stampoultzis 2004-09-19 01:34:09 UTC
We're not planning support for protected workbooks at this stage (it's in the
FAQ I believe).  It is unclear to us from a legal point of view whether we're
allowed to tackle decrypting protected workbooks so we're playing it safe.  If
you wish to independently tackle this feel free but unless we can get a clear
ruling on this it's probably not going to make it into POI proper.