NikhilMIT2013 / java-libpst

Automatically exported from code.google.com/p/java-libpst
0 stars 0 forks source link

Invalid Table Context (TC) RowIndex decoding in ANSI mode #45

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
When reading children objects of a folder in an ANSI PST file, we often get an 
"Unable to seek past end of item! ..." exception. By looking at the code, it 
looks like the RowIndex inside a Table Context (TC) is incorrectly decoded.

The code is located in the PSTTable7C constructor:

numberOfKeys = keyTableInfo.length() / (sizeOfItemKey+sizeOfItemValue);
offset = 0;
for (int x = 0; x < numberOfKeys; x++) {
    int Context = (int)keyTableInfo.seekAndReadLong(offset, 4);
    int RowIndex = (int)keyTableInfo.seekAndReadLong(offset+4, 4);
    keyMap.put(Context, RowIndex);
    offset += 8;
}

the problem is that in an ANSI file, the RowIndex size is 2 bytes long and not 
4.
I suggest to use a code like:

numberOfKeys = keyTableInfo.length() / (sizeOfItemKey+sizeOfItemValue);
offset = 0;
for (int x = 0; x < numberOfKeys; x++) {
    int Context = (int)keyTableInfo.seekAndReadLong(offset, sizeOfItemKey);
    offset += sizeOfItemKey;
    int RowIndex = (int)keyTableInfo.seekAndReadLong(offset, sizeOfItemValue);
    offset += sizeOfItemValue;
    keyMap.put(Context, RowIndex);
}

Original issue reported on code.google.com by luc.cl...@gmail.com on 15 Jul 2011 at 10:55

Attachments:

GoogleCodeExporter commented 8 years ago
Sexy! Thanks for picking this up, I've committed your fix.

Original comment by rjohnson...@gmail.com on 17 Jul 2011 at 5:19