From 9c30dd490a85a52b7852e3d2e465011a509a6159 Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Sat, 20 Mar 2010 14:28:09 -0500 Subject: [PATCH] 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. --- dlls/ole32/storage32.c | 18 +++++++++++++++--- dlls/ole32/storage32.h | 4 ++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/dlls/ole32/storage32.c b/dlls/ole32/storage32.c index f1706da..5de7640 100644 --- a/dlls/ole32/storage32.c +++ b/dlls/ole32/storage32.c @@ -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( StorageUtl_ReadDWord( headerBigBlock, + OFFSET_SMALLBLOCKLIMIT, + &This->smallBlockLimit); + + StorageUtl_ReadDWord( + headerBigBlock, OFFSET_SBDEPOTSTART, &This->smallBlockDepotStart); @@ -3382,9 +3388,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 @@ -3438,7 +3446,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( StorageUtl_WriteDWord( headerBigBlock, + OFFSET_SMALLBLOCKLIMIT, + This->smallBlockLimit); + + StorageUtl_WriteDWord( + headerBigBlock, OFFSET_SBDEPOTSTART, This->smallBlockDepotStart); diff --git a/dlls/ole32/storage32.h b/dlls/ole32/storage32.h index fad5d77..ce6becb 100644 --- a/dlls/ole32/storage32.h +++ b/dlls/ole32/storage32.h @@ -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; -- 1.6.3.3