Mike McCormack : msi: Fix tables with binary data where the key is an integer.

Alexandre Julliard julliard at wine.codeweavers.com
Tue Oct 17 06:12:29 CDT 2006


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

Author: Mike McCormack <mike at codeweavers.com>
Date:   Tue Oct 17 18:00:33 2006 +0900

msi: Fix tables with binary data where the key is an integer.

---

 dlls/msi/table.c    |   40 +++++++++++++++++++++++++++++-----------
 dlls/msi/tests/db.c |    2 --
 2 files changed, 29 insertions(+), 13 deletions(-)

diff --git a/dlls/msi/table.c b/dlls/msi/table.c
index 68d246a..087f407 100644
--- a/dlls/msi/table.c
+++ b/dlls/msi/table.c
@@ -27,16 +27,17 @@ #define NONAMELESSSTRUCT
 #include "windef.h"
 #include "winbase.h"
 #include "winerror.h"
-#include "wine/debug.h"
 #include "msi.h"
 #include "msiquery.h"
 #include "objbase.h"
 #include "objidl.h"
-#include "msipriv.h"
 #include "winnls.h"
-
+#include "msipriv.h"
 #include "query.h"
 
+#include "wine/debug.h"
+#include "wine/unicode.h"
+
 WINE_DEFAULT_DEBUG_CHANNEL(msidb);
 
 #define MSITABLE_HASH_TABLE_SIZE 37
@@ -1104,6 +1105,7 @@ static UINT TABLE_fetch_stream( struct t
     LPWSTR full_name;
     DWORD len;
     static const WCHAR szDot[] = { '.', 0 };
+    WCHAR number[0x20];
 
     if( !view->ops->fetch_int )
         return ERROR_INVALID_PARAMETER;
@@ -1118,15 +1120,31 @@ static UINT TABLE_fetch_stream( struct t
     if( r != ERROR_SUCCESS )
         return r;
 
-    /* now get the column with the name of the stream */
-    r = view->ops->fetch_int( view, row, ival, &refcol );
-    if( r != ERROR_SUCCESS )
-        return r;
+    /* check the column value is in range */
+    if (ival < 0 || ival > tv->num_cols || ival == col)
+    {
+        ERR("bad column ref (%u) for stream\n", ival);
+        return ERROR_FUNCTION_FAILED;
+    }
 
-    /* lookup the string value from the string table */
-    sval = msi_string_lookup_id( tv->db->strings, refcol );
-    if( !sval )
-        return ERROR_INVALID_PARAMETER;
+    if ( tv->columns[ival - 1].type & MSITYPE_STRING )
+    {
+        /* now get the column with the name of the stream */
+        r = view->ops->fetch_int( view, row, ival, &refcol );
+        if ( r != ERROR_SUCCESS )
+            return r;
+
+        /* lookup the string value from the string table */
+        sval = msi_string_lookup_id( tv->db->strings, refcol );
+        if ( !sval )
+            return ERROR_INVALID_PARAMETER;
+    }
+    else
+    {
+        static const WCHAR fmt[] = { '%','d',0 };
+        sprintfW( number, fmt, ival );
+        sval = number;
+    }
 
     len = lstrlenW( tv->name ) + 2 + lstrlenW( sval );
     full_name = msi_alloc( len*sizeof(WCHAR) );
diff --git a/dlls/msi/tests/db.c b/dlls/msi/tests/db.c
index f7dce1e..534c2d5 100644
--- a/dlls/msi/tests/db.c
+++ b/dlls/msi/tests/db.c
@@ -1983,7 +1983,6 @@ static void test_try_transform(void)
     r = do_query(hdb, query, &hrec);
     ok(r == ERROR_SUCCESS, "select query failed\n");
 
-    todo_wine {
     /* check the contents of the stream */
     sz = sizeof buffer;
     r = MsiRecordReadStream( hrec, 1, buffer, &sz );
@@ -1991,7 +1990,6 @@ static void test_try_transform(void)
     ok(!memcmp(buffer, "naengmyon", 9), "stream data was wrong\n");
     ok(sz == 9, "stream data was wrong size\n");
     if (hrec) MsiCloseHandle(hrec);
-    }
 
     MsiCloseHandle( hdb );
 




More information about the wine-cvs mailing list