Rob Shearman : msi: Fix loading string tables for databases that use 3-byte string references and that have a non-zero codepage (i.e. != CP_ACP).

Alexandre Julliard julliard at wine.codeweavers.com
Wed Jun 27 09:11:14 CDT 2007


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

Author: Rob Shearman <rob at codeweavers.com>
Date:   Tue Jun 26 22:24:05 2007 +0100

msi: Fix loading string tables for databases that use 3-byte string references and that have a non-zero codepage (i.e. != CP_ACP).

---

 dlls/msi/string.c |   18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/dlls/msi/string.c b/dlls/msi/string.c
index 932b624..9008249 100644
--- a/dlls/msi/string.c
+++ b/dlls/msi/string.c
@@ -81,6 +81,12 @@ static string_table *init_stringtable( int entries, UINT codepage )
     string_table *st;
     int i;
 
+    if (codepage != CP_ACP && !IsValidCodePage(codepage))
+    {
+        ERR("invalid codepage %d\n", codepage);
+        return NULL;
+    }
+
     st = msi_alloc( sizeof (string_table) );
     if( !st )
         return NULL;    
@@ -269,7 +275,6 @@ int msi_addstringW( string_table *st, UINT n, const WCHAR *data, int len, UINT r
     str = msi_alloc( (len+1)*sizeof(WCHAR) );
     if( !str )
         return -1;
-    TRACE("%d\n",__LINE__);
     memcpy( str, data, len*sizeof(WCHAR) );
     str[len] = 0;
 
@@ -516,8 +521,6 @@ string_table *msi_load_string_table( IStorage *stg, UINT *bytes_per_strref )
     UINT r, datasize = 0, poolsize = 0, codepage;
     DWORD i, count, offset, len, n, refs;
 
-    static const USHORT large_str_sig[] = { 0x0000, 0x8000 };
-
     r = read_stream_data( stg, szStringPool, &pool, &poolsize );
     if( r != ERROR_SUCCESS)
         goto end;
@@ -525,18 +528,19 @@ string_table *msi_load_string_table( IStorage *stg, UINT *bytes_per_strref )
     if( r != ERROR_SUCCESS)
         goto end;
 
-    if ( !memcmp(pool, large_str_sig, sizeof(large_str_sig)) )
+    if ( (poolsize > 4) && (pool[1] & 0x8000) )
         *bytes_per_strref = LONG_STR_BYTES;
     else
         *bytes_per_strref = sizeof(USHORT);
 
-    /* FIXME: don't know where the codepage is in large str tables */
     count = poolsize/4;
-    if( poolsize > 4 && *bytes_per_strref != LONG_STR_BYTES )
-        codepage = pool[0] | ( pool[1] << 16 );
+    if( poolsize > 4 )
+        codepage = pool[0] | ( (pool[1] & ~0x8000) << 16 );
     else
         codepage = CP_ACP;
     st = init_stringtable( count, codepage );
+    if (!st)
+        goto end;
 
     offset = 0;
     n = 1;




More information about the wine-cvs mailing list