msi: Preserve strings with embedded nulls when copying from a record to the string table.

This commit is contained in:
Hans Leidekker 2012-10-29 12:14:44 +01:00 committed by Alexandre Julliard
parent 9588deb54c
commit a7ff2818fe
1 changed files with 16 additions and 13 deletions

View File

@ -1273,10 +1273,11 @@ static UINT get_table_value_from_record( MSITABLEVIEW *tv, MSIRECORD *rec, UINT
} }
else if ( columninfo.type & MSITYPE_STRING ) else if ( columninfo.type & MSITYPE_STRING )
{ {
LPCWSTR sval = MSI_RecordGetString( rec, iField ); int len;
const WCHAR *sval = msi_record_get_string( rec, iField, &len );
if (sval) if (sval)
{ {
r = msi_string2id(tv->db->strings, sval, -1, pvalue); r = msi_string2id( tv->db->strings, sval, len, pvalue );
if (r != ERROR_SUCCESS) if (r != ERROR_SUCCESS)
return ERROR_NOT_FOUND; return ERROR_NOT_FOUND;
} }
@ -1360,8 +1361,9 @@ static UINT TABLE_set_row( struct tagMSIVIEW *view, UINT row, MSIRECORD *rec, UI
if ( r != ERROR_SUCCESS ) if ( r != ERROR_SUCCESS )
{ {
LPCWSTR sval = MSI_RecordGetString( rec, i + 1 ); int len;
val = msi_addstringW( tv->db->strings, sval, -1, 1, const WCHAR *sval = msi_record_get_string( rec, i + 1, &len );
val = msi_addstringW( tv->db->strings, sval, len, 1,
persistent ? StringPersistent : StringNonPersistent ); persistent ? StringPersistent : StringNonPersistent );
} }
else else
@ -1530,10 +1532,10 @@ static UINT table_validate_new( MSITABLEVIEW *tv, MSIRECORD *rec, UINT *column )
TRACE("skipping binary column\n"); TRACE("skipping binary column\n");
else if ( tv->columns[i].type & MSITYPE_STRING ) else if ( tv->columns[i].type & MSITYPE_STRING )
{ {
LPCWSTR str; int len;
const WCHAR *str = msi_record_get_string( rec, i+1, &len );
str = MSI_RecordGetString( rec, i+1 ); if (!str || (!str[0] && !len))
if (str == NULL || str[0] == 0)
{ {
if (column) *column = i; if (column) *column = i;
return ERROR_INVALID_DATA; return ERROR_INVALID_DATA;
@ -2383,12 +2385,13 @@ static void dump_record( MSIRECORD *rec )
n = MSI_RecordGetFieldCount( rec ); n = MSI_RecordGetFieldCount( rec );
for( i=1; i<=n; i++ ) for( i=1; i<=n; i++ )
{ {
LPCWSTR sval; int len;
const WCHAR *sval;
if( MSI_RecordIsNull( rec, i ) ) if( MSI_RecordIsNull( rec, i ) )
TRACE("row -> []\n"); TRACE("row -> []\n");
else if( (sval = MSI_RecordGetString( rec, i )) ) else if( (sval = msi_record_get_string( rec, i, &len )) )
TRACE("row -> [%s]\n", debugstr_w(sval)); TRACE("row -> [%s]\n", debugstr_wn(sval, len));
else else
TRACE("row -> [0x%08x]\n", MSI_RecordGetInteger( rec, i ) ); TRACE("row -> [0x%08x]\n", MSI_RecordGetInteger( rec, i ) );
} }
@ -2407,7 +2410,6 @@ static void dump_table( const string_table *st, const USHORT *rawdata, UINT raws
static UINT* msi_record_to_row( const MSITABLEVIEW *tv, MSIRECORD *rec ) static UINT* msi_record_to_row( const MSITABLEVIEW *tv, MSIRECORD *rec )
{ {
LPCWSTR str;
UINT i, r, *data; UINT i, r, *data;
data = msi_alloc( tv->num_cols *sizeof (UINT) ); data = msi_alloc( tv->num_cols *sizeof (UINT) );
@ -2422,10 +2424,11 @@ static UINT* msi_record_to_row( const MSITABLEVIEW *tv, MSIRECORD *rec )
if ( ( tv->columns[i].type & MSITYPE_STRING ) && if ( ( tv->columns[i].type & MSITYPE_STRING ) &&
! MSITYPE_IS_BINARY(tv->columns[i].type) ) ! MSITYPE_IS_BINARY(tv->columns[i].type) )
{ {
str = MSI_RecordGetString( rec, i+1 ); int len;
const WCHAR *str = msi_record_get_string( rec, i+1, &len );
if (str) if (str)
{ {
r = msi_string2id( tv->db->strings, str, -1, &data[i] ); r = msi_string2id( tv->db->strings, str, len, &data[i] );
/* if there's no matching string in the string table, /* if there's no matching string in the string table,
these keys can't match any record, so fail now. */ these keys can't match any record, so fail now. */