Vincent Povirk : ole32: Check the small block size limit of storage files.

Alexandre Julliard julliard at winehq.org
Mon Mar 22 11:12:00 CDT 2010


Module: wine
Branch: master
Commit: 49a817c064e73e60173914306dd81d95690f3923
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=49a817c064e73e60173914306dd81d95690f3923

Author: Vincent Povirk <vincent at codeweavers.com>
Date:   Sat Mar 20 14:28:09 2010 -0500

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 a15e3db..e1ba8a3 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;
@@ -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);
 
diff --git a/dlls/ole32/storage32.h b/dlls/ole32/storage32.h
index dfa5d1a..98ec6d1 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;




More information about the wine-cvs mailing list