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

This commit is contained in:
Mike McCormack 2006-08-24 20:19:43 +09:00 committed by Alexandre Julliard
parent f667c06a0c
commit 089411747b
1 changed files with 29 additions and 16 deletions

View File

@ -686,7 +686,7 @@ string_table *load_string_table( IStorage *stg )
CHAR *data = NULL; CHAR *data = NULL;
USHORT *pool = NULL; USHORT *pool = NULL;
UINT r, datasize = 0, poolsize = 0, codepage; UINT r, datasize = 0, poolsize = 0, codepage;
DWORD i, count, offset, len, n; DWORD i, count, offset, len, n, refs;
static const WCHAR szStringData[] = { static const WCHAR szStringData[] = {
'_','S','t','r','i','n','g','D','a','t','a',0 }; '_','S','t','r','i','n','g','D','a','t','a',0 };
static const WCHAR szStringPool[] = { static const WCHAR szStringPool[] = {
@ -708,38 +708,51 @@ string_table *load_string_table( IStorage *stg )
offset = 0; offset = 0;
n = 1; 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 * 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 * and its the high word of the length is inserted in the null string's
* reference count field. * reference count field.
*/ */
if( pool[i*2-2] == 0 && pool[i*2-1] ) if( pool[i*2] == 0)
len += pool[i*2+1] * 0x10000; {
len = (pool[i*2+3] << 16) + pool[i*2+2];
i += 2;
}
else
{
len = pool[i*2];
i += 1;
}
if( (offset + len) > datasize ) if ( (offset + len) > datasize )
{ {
ERR("string table corrupt?\n"); ERR("string table corrupt?\n");
break; break;
} }
/* don't add the high word of a string's length as a string */ r = msi_addstring( st, n, data+offset, len, refs );
if ( len || !pool[i*2+1] ) if( r != n )
{ ERR("Failed to add string %ld\n", n );
r = msi_addstring( st, n, data+offset, len, pool[i*2+1] ); n++;
if( r != n )
ERR("Failed to add string %ld\n", n );
n++;
}
offset += len; offset += len;
} }
if ( datasize != offset ) 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); TRACE("Loaded %ld strings\n", count);