Commit 49a817c0 authored by Vincent Povirk's avatar Vincent Povirk Committed by Alexandre Julliard

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.
parent 975c820f
......@@ -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;
......@@ -3352,6 +3353,11 @@ static HRESULT StorageImpl_LoadFileHeader(
StorageUtl_ReadDWord(
headerBigBlock,
OFFSET_SMALLBLOCKLIMIT,
&This->smallBlockLimit);
StorageUtl_ReadDWord(
headerBigBlock,
OFFSET_SBDEPOTSTART,
&This->smallBlockDepotStart);
......@@ -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);
}
/*
......@@ -3468,6 +3475,11 @@ static void StorageImpl_SaveFileHeader(
StorageUtl_WriteDWord(
headerBigBlock,
OFFSET_SMALLBLOCKLIMIT,
This->smallBlockLimit);
StorageUtl_WriteDWord(
headerBigBlock,
OFFSET_SBDEPOTSTART,
This->smallBlockDepotStart);
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment