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

Alexandre Julliard julliard at winehq.org
Mon Oct 29 13:52:52 CDT 2012


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

Author: Hans Leidekker <hans at codeweavers.com>
Date:   Mon Oct 29 12:14:44 2012 +0100

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

---

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

diff --git a/dlls/msi/table.c b/dlls/msi/table.c
index 78c00b1..a7798e5 100644
--- a/dlls/msi/table.c
+++ b/dlls/msi/table.c
@@ -1273,10 +1273,11 @@ static UINT get_table_value_from_record( MSITABLEVIEW *tv, MSIRECORD *rec, UINT
     }
     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)
         {
-            r = msi_string2id(tv->db->strings, sval, -1, pvalue);
+            r = msi_string2id( tv->db->strings, sval, len, pvalue );
             if (r != ERROR_SUCCESS)
                 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 )
                 {
-                    LPCWSTR sval = MSI_RecordGetString( rec, i + 1 );
-                    val = msi_addstringW( tv->db->strings, sval, -1, 1,
+                    int len;
+                    const WCHAR *sval = msi_record_get_string( rec, i + 1, &len );
+                    val = msi_addstringW( tv->db->strings, sval, len, 1,
                       persistent ? StringPersistent : StringNonPersistent );
                 }
                 else
@@ -1530,10 +1532,10 @@ static UINT table_validate_new( MSITABLEVIEW *tv, MSIRECORD *rec, UINT *column )
             TRACE("skipping binary column\n");
         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 == NULL || str[0] == 0)
+            if (!str || (!str[0] && !len))
             {
                 if (column) *column = i;
                 return ERROR_INVALID_DATA;
@@ -2383,12 +2385,13 @@ static void dump_record( MSIRECORD *rec )
     n = MSI_RecordGetFieldCount( rec );
     for( i=1; i<=n; i++ )
     {
-        LPCWSTR sval;
+        int len;
+        const WCHAR *sval;
 
         if( MSI_RecordIsNull( rec, i ) )
             TRACE("row -> []\n");
-        else if( (sval = MSI_RecordGetString( rec, i )) )
-            TRACE("row -> [%s]\n", debugstr_w(sval));
+        else if( (sval = msi_record_get_string( rec, i, &len )) )
+            TRACE("row -> [%s]\n", debugstr_wn(sval, len));
         else
             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 )
 {
-    LPCWSTR str;
     UINT i, r, *data;
 
     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 ) &&
              ! 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)
             {
-                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,
                    these keys can't match any record, so fail now. */




More information about the wine-cvs mailing list