Mike McCormack : msi: Fix strings with lengths that are exact multiples of 2^16.

Alexandre Julliard julliard at wine.codeweavers.com
Thu Aug 24 07:55:54 CDT 2006


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

Author: Mike McCormack <mike at codeweavers.com>
Date:   Thu Aug 24 20:19:43 2006 +0900

msi: Fix strings with lengths that are exact multiples of 2^16.

---

 dlls/msi/table.c |   45 +++++++++++++++++++++++++++++----------------
 1 files changed, 29 insertions(+), 16 deletions(-)

diff --git a/dlls/msi/table.c b/dlls/msi/table.c
index 1a3ccb2..57cd4df 100644
--- a/dlls/msi/table.c
+++ b/dlls/msi/table.c
@@ -686,7 +686,7 @@ string_table *load_string_table( IStorag
     CHAR *data = NULL;
     USHORT *pool = NULL;
     UINT r, datasize = 0, poolsize = 0, codepage;
-    DWORD i, count, offset, len, n;
+    DWORD i, count, offset, len, n, refs;
     static const WCHAR szStringData[] = {
         '_','S','t','r','i','n','g','D','a','t','a',0 };
     static const WCHAR szStringPool[] = {
@@ -708,38 +708,51 @@ string_table *load_string_table( IStorag
 
     offset = 0;
     n = 1;
-    for( i=1; i<count; i++ )
+    i = 1;
+    while( i<count )
     {
-        len = pool[i*2];
+        /* the string reference count is always the second word */
+        refs = pool[i*2+1];
+
+        /* empty entries have two zeros, still have a string id */
+        if (pool[i*2] == 0 && refs == 0)
+        {
+            i++;
+            n++;
+            continue;
+        }
 
         /*
          * If a string is over 64k, the previous string entry is made null
          * and its the high word of the length is inserted in the null string's
          * reference count field.
          */
-        if( pool[i*2-2] == 0 && pool[i*2-1] )
-            len += pool[i*2+1] * 0x10000;
-
-        if( (offset + len) > datasize )
+        if( pool[i*2] == 0)
         {
-            ERR("string table corrupt?\n");
-            break;
+            len = (pool[i*2+3] << 16) + pool[i*2+2];
+            i += 2;
+        }
+        else
+        {
+            len = pool[i*2];
+            i += 1;
         }
 
-        /* don't add the high word of a string's length as a string */
-        if ( len || !pool[i*2+1] )
+        if ( (offset + len) > datasize )
         {
-            r = msi_addstring( st, n, data+offset, len, pool[i*2+1] );
-            if( r != n )
-                ERR("Failed to add string %ld\n", n );
-            n++;
+            ERR("string table corrupt?\n");
+            break;
         }
 
+        r = msi_addstring( st, n, data+offset, len, refs );
+        if( r != n )
+            ERR("Failed to add string %ld\n", n );
+        n++;
         offset += len;
     }
 
     if ( datasize != offset )
-        ERR("string table load failed! (%08x != %08lx)\n", datasize, offset );
+        ERR("string table load failed! (%08x != %08lx), please report\n", datasize, offset );
 
     TRACE("Loaded %ld strings\n", count);
 




More information about the wine-cvs mailing list