Document that this is known as StructuredStorageDirectoryEntry in the spec

This commit is contained in:
Caolán McNamara
2011-10-01 15:34:08 +01:00
parent 6017ef2520
commit 542c93d10d
2 changed files with 12 additions and 5 deletions

View File

@@ -40,6 +40,8 @@
#include "stgdir.hxx" #include "stgdir.hxx"
#include "stgio.hxx" #include "stgio.hxx"
static const sal_uInt16 nMaxLegalStr = 31;
static sal_uInt8 cStgSignature[ 8 ] = { 0xD0,0xCF,0x11,0xE0,0xA1,0xB1,0x1A,0xE1 }; static sal_uInt8 cStgSignature[ 8 ] = { 0xD0,0xCF,0x11,0xE0,0xA1,0xB1,0x1A,0xE1 };
////////////////////////////// struct ClsId ///////////////////////////// ////////////////////////////// struct ClsId /////////////////////////////
@@ -255,7 +257,7 @@ sal_Bool StgEntry::SetName( const String& rName )
{ {
// I don't know the locale, so en_US is hopefully fine // I don't know the locale, so en_US is hopefully fine
aName = ToUpperUnicode( rName ); aName = ToUpperUnicode( rName );
aName.Erase( 31 ); aName.Erase( nMaxLegalStr );
int i; int i;
for( i = 0; i < aName.Len() && i < 32; i++ ) for( i = 0; i < aName.Len() && i < 32; i++ )
@@ -346,9 +348,13 @@ sal_Bool StgEntry::Load( const void* pFrom )
sal_uInt16 n = nNameLen; sal_uInt16 n = nNameLen;
if( n ) if( n )
n = ( n >> 1 ) - 1; n = ( n >> 1 ) - 1;
if( n > 31 || (nSize < 0 && cType != STG_STORAGE) )
if (n > nMaxLegalStr)
return sal_False;
if (nSize < 0 && cType != STG_STORAGE)
{ {
// the size makes no sence for the substorage // the size makes no sense for the substorage
// TODO/LATER: actually the size should be an unsigned value, but in this case it would mean a stream of more than 2Gb // TODO/LATER: actually the size should be an unsigned value, but in this case it would mean a stream of more than 2Gb
return sal_False; return sal_False;
} }
@@ -356,7 +362,7 @@ sal_Bool StgEntry::Load( const void* pFrom )
aName = String( nName, n ); aName = String( nName, n );
// I don't know the locale, so en_US is hopefully fine // I don't know the locale, so en_US is hopefully fine
aName = ToUpperUnicode( aName ); aName = ToUpperUnicode( aName );
aName.Erase( 31 ); aName.Erase( nMaxLegalStr );
return sal_True; return sal_True;
} }

View File

@@ -117,9 +117,10 @@ class StgStream;
#define STGENTRY_SIZE 128 #define STGENTRY_SIZE 128
//StructuredStorageDirectoryEntry
class StgEntry { // directory enty class StgEntry { // directory enty
sal_uInt16 nName[ 32 ]; // 00 name as WCHAR sal_uInt16 nName[ 32 ]; // 00 name as WCHAR
sal_Int16 nNameLen; // 40 size of name in bytes including 00H sal_uInt16 nNameLen; // 40 size of name in bytes including 00H
sal_uInt8 cType; // 42 entry type sal_uInt8 cType; // 42 entry type
sal_uInt8 cFlags; // 43 0 or 1 (tree balance?) sal_uInt8 cFlags; // 43 0 or 1 (tree balance?)
sal_Int32 nLeft; // 44 left node entry sal_Int32 nLeft; // 44 left node entry