Commit 98a42ad5 authored by Mike McCormack's avatar Mike McCormack Committed by Alexandre Julliard

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

parent 1f737c03
...@@ -27,16 +27,17 @@ ...@@ -27,16 +27,17 @@
#include "windef.h" #include "windef.h"
#include "winbase.h" #include "winbase.h"
#include "winerror.h" #include "winerror.h"
#include "wine/debug.h"
#include "msi.h" #include "msi.h"
#include "msiquery.h" #include "msiquery.h"
#include "objbase.h" #include "objbase.h"
#include "objidl.h" #include "objidl.h"
#include "msipriv.h"
#include "winnls.h" #include "winnls.h"
#include "msipriv.h"
#include "query.h" #include "query.h"
#include "wine/debug.h"
#include "wine/unicode.h"
WINE_DEFAULT_DEBUG_CHANNEL(msidb); WINE_DEFAULT_DEBUG_CHANNEL(msidb);
#define MSITABLE_HASH_TABLE_SIZE 37 #define MSITABLE_HASH_TABLE_SIZE 37
...@@ -1104,6 +1105,7 @@ static UINT TABLE_fetch_stream( struct tagMSIVIEW *view, UINT row, UINT col, ISt ...@@ -1104,6 +1105,7 @@ static UINT TABLE_fetch_stream( struct tagMSIVIEW *view, UINT row, UINT col, ISt
LPWSTR full_name; LPWSTR full_name;
DWORD len; DWORD len;
static const WCHAR szDot[] = { '.', 0 }; static const WCHAR szDot[] = { '.', 0 };
WCHAR number[0x20];
if( !view->ops->fetch_int ) if( !view->ops->fetch_int )
return ERROR_INVALID_PARAMETER; return ERROR_INVALID_PARAMETER;
...@@ -1118,15 +1120,31 @@ static UINT TABLE_fetch_stream( struct tagMSIVIEW *view, UINT row, UINT col, ISt ...@@ -1118,15 +1120,31 @@ static UINT TABLE_fetch_stream( struct tagMSIVIEW *view, UINT row, UINT col, ISt
if( r != ERROR_SUCCESS ) if( r != ERROR_SUCCESS )
return r; return r;
/* now get the column with the name of the stream */ /* check the column value is in range */
r = view->ops->fetch_int( view, row, ival, &refcol ); if (ival < 0 || ival > tv->num_cols || ival == col)
if( r != ERROR_SUCCESS ) {
return r; ERR("bad column ref (%u) for stream\n", ival);
return ERROR_FUNCTION_FAILED;
}
/* lookup the string value from the string table */ if ( tv->columns[ival - 1].type & MSITYPE_STRING )
sval = msi_string_lookup_id( tv->db->strings, refcol ); {
if( !sval ) /* now get the column with the name of the stream */
return ERROR_INVALID_PARAMETER; 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 ); len = lstrlenW( tv->name ) + 2 + lstrlenW( sval );
full_name = msi_alloc( len*sizeof(WCHAR) ); full_name = msi_alloc( len*sizeof(WCHAR) );
......
...@@ -1983,7 +1983,6 @@ static void test_try_transform(void) ...@@ -1983,7 +1983,6 @@ static void test_try_transform(void)
r = do_query(hdb, query, &hrec); r = do_query(hdb, query, &hrec);
ok(r == ERROR_SUCCESS, "select query failed\n"); ok(r == ERROR_SUCCESS, "select query failed\n");
todo_wine {
/* check the contents of the stream */ /* check the contents of the stream */
sz = sizeof buffer; sz = sizeof buffer;
r = MsiRecordReadStream( hrec, 1, buffer, &sz ); r = MsiRecordReadStream( hrec, 1, buffer, &sz );
...@@ -1991,7 +1990,6 @@ static void test_try_transform(void) ...@@ -1991,7 +1990,6 @@ static void test_try_transform(void)
ok(!memcmp(buffer, "naengmyon", 9), "stream data was wrong\n"); ok(!memcmp(buffer, "naengmyon", 9), "stream data was wrong\n");
ok(sz == 9, "stream data was wrong size\n"); ok(sz == 9, "stream data was wrong size\n");
if (hrec) MsiCloseHandle(hrec); if (hrec) MsiCloseHandle(hrec);
}
MsiCloseHandle( hdb ); MsiCloseHandle( hdb );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment