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;
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( IStorage *stg )
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( pool[i*2] == 0)
{
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");
break;
}
/* don't add the high word of a string's length as a string */
if ( len || !pool[i*2+1] )
{
r = msi_addstring( st, n, data+offset, len, pool[i*2+1] );
if( r != n )
ERR("Failed to add string %ld\n", n );
n++;
}
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);