ole32: Check the small block size limit of storage files.
This value is stored in the storage file header. We currently hard-code it to 0x1000. I don't expect to see files in the wild with other values, but according to MS this is a valid configuration. For now, just fail if we see another value. I've also upgraded the message for unexpected values in storage file headers to a fixme, since they are valid according to MS.
This commit is contained in:
parent
975c820fce
commit
49a817c064
|
@ -2665,6 +2665,7 @@ static HRESULT StorageImpl_Construct(
|
|||
This->bigBlockDepotCount = 1;
|
||||
This->bigBlockDepotStart[0] = 0;
|
||||
This->rootStartBlock = 1;
|
||||
This->smallBlockLimit = LIMIT_TO_USE_SMALL_BLOCK;
|
||||
This->smallBlockDepotStart = BLOCK_END_OF_CHAIN;
|
||||
This->bigBlockSizeBits = DEF_BIG_BLOCK_SIZE_BITS;
|
||||
This->smallBlockSizeBits = DEF_SMALL_BLOCK_SIZE_BITS;
|
||||
|
@ -3350,6 +3351,11 @@ static HRESULT StorageImpl_LoadFileHeader(
|
|||
OFFSET_ROOTSTARTBLOCK,
|
||||
&This->rootStartBlock);
|
||||
|
||||
StorageUtl_ReadDWord(
|
||||
headerBigBlock,
|
||||
OFFSET_SMALLBLOCKLIMIT,
|
||||
&This->smallBlockLimit);
|
||||
|
||||
StorageUtl_ReadDWord(
|
||||
headerBigBlock,
|
||||
OFFSET_SBDEPOTSTART,
|
||||
|
@ -3384,9 +3390,11 @@ static HRESULT StorageImpl_LoadFileHeader(
|
|||
* blocks, just make sure they are what we're expecting.
|
||||
*/
|
||||
if ((This->bigBlockSize != MIN_BIG_BLOCK_SIZE && This->bigBlockSize != MAX_BIG_BLOCK_SIZE) ||
|
||||
This->smallBlockSize != DEF_SMALL_BLOCK_SIZE)
|
||||
This->smallBlockSize != DEF_SMALL_BLOCK_SIZE ||
|
||||
This->smallBlockLimit != LIMIT_TO_USE_SMALL_BLOCK)
|
||||
{
|
||||
WARN("Broken OLE storage file\n");
|
||||
FIXME("Broken OLE storage file? bigblock=0x%x, smallblock=0x%x, sblimit=0x%x\n",
|
||||
This->bigBlockSize, This->smallBlockSize, This->smallBlockLimit);
|
||||
hr = STG_E_INVALIDHEADER;
|
||||
}
|
||||
else
|
||||
|
@ -3440,7 +3448,6 @@ static void StorageImpl_SaveFileHeader(
|
|||
StorageUtl_WriteWord(headerBigBlock, 0x18, 0x3b);
|
||||
StorageUtl_WriteWord(headerBigBlock, 0x1a, 0x3);
|
||||
StorageUtl_WriteWord(headerBigBlock, 0x1c, (WORD)-2);
|
||||
StorageUtl_WriteDWord(headerBigBlock, 0x38, (DWORD)0x1000);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -3466,6 +3473,11 @@ static void StorageImpl_SaveFileHeader(
|
|||
OFFSET_ROOTSTARTBLOCK,
|
||||
This->rootStartBlock);
|
||||
|
||||
StorageUtl_WriteDWord(
|
||||
headerBigBlock,
|
||||
OFFSET_SMALLBLOCKLIMIT,
|
||||
This->smallBlockLimit);
|
||||
|
||||
StorageUtl_WriteDWord(
|
||||
headerBigBlock,
|
||||
OFFSET_SBDEPOTSTART,
|
||||
|
|
|
@ -46,6 +46,7 @@ static const ULONG OFFSET_BIGBLOCKSIZEBITS = 0x0000001e;
|
|||
static const ULONG OFFSET_SMALLBLOCKSIZEBITS = 0x00000020;
|
||||
static const ULONG OFFSET_BBDEPOTCOUNT = 0x0000002C;
|
||||
static const ULONG OFFSET_ROOTSTARTBLOCK = 0x00000030;
|
||||
static const ULONG OFFSET_SMALLBLOCKLIMIT = 0x00000038;
|
||||
static const ULONG OFFSET_SBDEPOTSTART = 0x0000003C;
|
||||
static const ULONG OFFSET_SBDEPOTCOUNT = 0x00000040;
|
||||
static const ULONG OFFSET_EXTBBDEPOTSTART = 0x00000044;
|
||||
|
@ -97,6 +98,8 @@ static const ULONG DIRENTRY_NULL = 0xFFFFFFFF;
|
|||
#define STGTY_ROOT 0x05
|
||||
|
||||
#define COUNT_BBDEPOTINHEADER 109
|
||||
|
||||
/* FIXME: This value is stored in the header, but we hard-code it to 0x1000. */
|
||||
#define LIMIT_TO_USE_SMALL_BLOCK 0x1000
|
||||
|
||||
#define STGM_ACCESS_MODE(stgm) ((stgm)&0x0000f)
|
||||
|
@ -351,6 +354,7 @@ struct StorageImpl
|
|||
ULONG smallBlockSize;
|
||||
ULONG bigBlockDepotCount;
|
||||
ULONG rootStartBlock;
|
||||
ULONG smallBlockLimit;
|
||||
ULONG smallBlockDepotStart;
|
||||
ULONG extBigBlockDepotStart;
|
||||
ULONG extBigBlockDepotCount;
|
||||
|
|
Loading…
Reference in New Issue