ChangeSet ID: 21192 CVSROOT: /opt/cvs-commit Module name: wine Changes by: julliard@winehq.org 2005/11/09 04:59:20
Modified files: dlls/msi/tests : db.c dlls/msi : registry.c
Log message: Mike McCormack mike@codeweavers.com Fix passing of NULL pointers to MsiDecomposeDescriptor and add a test.
Patch: http://cvs.winehq.org/patch.py?id=21192
Old revision New revision Changes Path 1.17 1.18 +26 -6 wine/dlls/msi/tests/db.c 1.12 1.13 +27 -15 wine/dlls/msi/registry.c
Index: wine/dlls/msi/tests/db.c diff -u -p wine/dlls/msi/tests/db.c:1.17 wine/dlls/msi/tests/db.c:1.18 --- wine/dlls/msi/tests/db.c:1.17 9 Nov 2005 10:59:20 -0000 +++ wine/dlls/msi/tests/db.c 9 Nov 2005 10:59:20 -0000 @@ -128,7 +128,7 @@ static void test_msiinsert(void) }
typedef UINT (WINAPI *fnMsiDecomposeDescriptorA)(LPCSTR, LPCSTR, LPSTR, LPSTR, DWORD *); -fnMsiDecomposeDescriptorA MsiDecomposeDescriptorA; +static fnMsiDecomposeDescriptorA pMsiDecomposeDescriptorA;
static void test_msidecomposedesc(void) { @@ -141,15 +141,15 @@ static void test_msidecomposedesc(void) hmod = GetModuleHandle("msi.dll"); if (!hmod) return; - MsiDecomposeDescriptorA = (fnMsiDecomposeDescriptorA) + pMsiDecomposeDescriptorA = (fnMsiDecomposeDescriptorA) GetProcAddress(hmod, "MsiDecomposeDescriptorA"); - if (!MsiDecomposeDescriptorA) + if (!pMsiDecomposeDescriptorA) return;
/* test a valid feature descriptor */ desc = "']gAVn-}f(ZXfeAR6.jiFollowTheWhiteRabbit>3w2x^IGfe?CxI5heAvk."; len = 0; - r = MsiDecomposeDescriptorA(desc, prod, feature, comp, &len); + r = pMsiDecomposeDescriptorA(desc, prod, feature, comp, &len); ok(r == ERROR_SUCCESS, "returned an error\n"); ok(len == strlen(desc), "length was wrong\n"); ok(strcmp(prod,"{90110409-6000-11D3-8CFE-0150048383C9}")==0, "product wrong\n"); @@ -161,7 +161,7 @@ static void test_msidecomposedesc(void) "ThisWillFailIfTheresMoreThanAGuidsChars>" "3w2x^IGfe?CxI5heAvk."; len = 0; - r = MsiDecomposeDescriptorA(desc, prod, feature, comp, &len); + r = pMsiDecomposeDescriptorA(desc, prod, feature, comp, &len); ok(r == ERROR_INVALID_PARAMETER, "returned wrong error\n");
/* @@ -173,9 +173,29 @@ static void test_msidecomposedesc(void) "3w2x^IGfe?CxI5heAvk." "extra"; len = 0; - r = MsiDecomposeDescriptorA(desc, prod, feature, comp, &len); + r = pMsiDecomposeDescriptorA(desc, prod, feature, comp, &len); ok(r == ERROR_SUCCESS, "returned wrong error\n"); ok(len == (strlen(desc) - strlen("extra")), "length wrong\n"); + + len = 0; + r = pMsiDecomposeDescriptorA(desc, prod, feature, NULL, &len); + ok(r == ERROR_SUCCESS, "returned wrong error\n"); + ok(len == (strlen(desc) - strlen("extra")), "length wrong\n"); + + len = 0; + r = pMsiDecomposeDescriptorA(desc, prod, NULL, NULL, &len); + ok(r == ERROR_SUCCESS, "returned wrong error\n"); + ok(len == (strlen(desc) - strlen("extra")), "length wrong\n"); + + len = 0; + r = pMsiDecomposeDescriptorA(desc, NULL, NULL, NULL, &len); + ok(r == ERROR_SUCCESS, "returned wrong error\n"); + ok(len == (strlen(desc) - strlen("extra")), "length wrong\n"); + + len = 0; + r = pMsiDecomposeDescriptorA(NULL, NULL, NULL, NULL, &len); + ok(r == ERROR_INVALID_PARAMETER, "returned wrong error\n"); + ok(len == 0, "length wrong\n"); }
static UINT try_query_param( MSIHANDLE hdb, LPCSTR szQuery, MSIHANDLE hrec ) Index: wine/dlls/msi/registry.c diff -u -p wine/dlls/msi/registry.c:1.12 wine/dlls/msi/registry.c:1.13 --- wine/dlls/msi/registry.c:1.12 9 Nov 2005 10:59:20 -0000 +++ wine/dlls/msi/registry.c 9 Nov 2005 10:59:20 -0000 @@ -253,6 +253,9 @@ BOOL decode_base85_guid( LPCWSTR str, GU { DWORD i, val = 0, base = 1, *p;
+ if (!str) + return FALSE; + p = (DWORD*) guid; for( i=0; i<20; i++ ) { @@ -532,8 +535,11 @@ UINT WINAPI MsiDecomposeDescriptorW( LPC len = (p - &szDescriptor[20]); if( len > MAX_FEATURE_CHARS ) return ERROR_INVALID_PARAMETER; - memcpy( szFeature, &szDescriptor[20], len*sizeof(WCHAR) ); - szFeature[len] = 0; + if (szFeature) + { + memcpy( szFeature, &szDescriptor[20], len*sizeof(WCHAR) ); + szFeature[len] = 0; + }
TRACE("feature %s\n", debugstr_w( szFeature ));
@@ -543,8 +549,10 @@ UINT WINAPI MsiDecomposeDescriptorW( LPC
TRACE("component %s\n", debugstr_guid( &component ));
- StringFromGUID2( &product, szProduct, MAX_FEATURE_CHARS+1 ); - StringFromGUID2( &component, szComponent, MAX_FEATURE_CHARS+1 ); + if (szProduct) + StringFromGUID2( &product, szProduct, MAX_FEATURE_CHARS+1 ); + if (szComponent) + StringFromGUID2( &component, szComponent, MAX_FEATURE_CHARS+1 ); len = ( &p[21] - szDescriptor );
TRACE("length = %d\n", len); @@ -559,26 +567,30 @@ UINT WINAPI MsiDecomposeDescriptorA( LPC WCHAR product[MAX_FEATURE_CHARS+1]; WCHAR feature[MAX_FEATURE_CHARS+1]; WCHAR component[MAX_FEATURE_CHARS+1]; - LPWSTR str = NULL; + LPWSTR str = NULL, p = NULL, f = NULL, c = NULL; UINT r;
TRACE("%s %p %p %p %p\n", debugstr_a(szDescriptor), szProduct, szFeature, szComponent, pUsed);
- if( szDescriptor ) - { - str = strdupAtoW( szDescriptor ); - if( !str ) - return ERROR_OUTOFMEMORY; - } + str = strdupAtoW( szDescriptor ); + if( szDescriptor && !str ) + return ERROR_OUTOFMEMORY; + + if (szProduct) + p = product; + if (szFeature) + f = feature; + if (szComponent) + c = component;
- r = MsiDecomposeDescriptorW( str, product, feature, component, pUsed ); + r = MsiDecomposeDescriptorW( str, p, f, c, pUsed );
- WideCharToMultiByte( CP_ACP, 0, product, MAX_FEATURE_CHARS+1, + WideCharToMultiByte( CP_ACP, 0, p, MAX_FEATURE_CHARS+1, szProduct, MAX_FEATURE_CHARS+1, NULL, NULL ); - WideCharToMultiByte( CP_ACP, 0, feature, MAX_FEATURE_CHARS+1, + WideCharToMultiByte( CP_ACP, 0, f, MAX_FEATURE_CHARS+1, szFeature, MAX_FEATURE_CHARS+1, NULL, NULL ); - WideCharToMultiByte( CP_ACP, 0, component, MAX_FEATURE_CHARS+1, + WideCharToMultiByte( CP_ACP, 0, c, MAX_FEATURE_CHARS+1, szComponent, MAX_FEATURE_CHARS+1, NULL, NULL );
msi_free( str );