Fix passing of NULL pointers to MsiDecomposeDescriptor and add a
test.
This commit is contained in:
parent
454fa4bea0
commit
5c63332b4f
|
@ -253,6 +253,9 @@ BOOL decode_base85_guid( LPCWSTR str, GUID *guid )
|
|||
{
|
||||
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( LPCWSTR szDescriptor, LPWSTR szProduct,
|
|||
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( LPCWSTR szDescriptor, LPWSTR szProduct,
|
|||
|
||||
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( LPCSTR szDescriptor, LPSTR szProduct,
|
|||
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;
|
||||
|
||||
r = MsiDecomposeDescriptorW( str, product, feature, component, pUsed );
|
||||
if (szProduct)
|
||||
p = product;
|
||||
if (szFeature)
|
||||
f = feature;
|
||||
if (szComponent)
|
||||
c = component;
|
||||
|
||||
WideCharToMultiByte( CP_ACP, 0, product, MAX_FEATURE_CHARS+1,
|
||||
r = MsiDecomposeDescriptorW( str, p, f, c, pUsed );
|
||||
|
||||
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 );
|
||||
|
|
|
@ -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 )
|
||||
|
|
Loading…
Reference in New Issue