msi: Validate packages based on supported version, platform and languages.

This commit is contained in:
Hans Leidekker 2010-10-06 15:44:08 +02:00 committed by Alexandre Julliard
parent 8bc9a499d1
commit ca7cd1bf89
3 changed files with 50 additions and 1 deletions

View File

@ -315,6 +315,7 @@ typedef struct tagMSIPACKAGE
{ {
MSIOBJECTHDR hdr; MSIOBJECTHDR hdr;
MSIDATABASE *db; MSIDATABASE *db;
INT version;
enum platform platform; enum platform platform;
UINT num_langids; UINT num_langids;
LANGID *langids; LANGID *langids;
@ -855,6 +856,7 @@ extern UINT msi_spawn_error_dialog( MSIPACKAGE*, LPWSTR, LPWSTR );
/* summary information */ /* summary information */
extern MSISUMMARYINFO *MSI_GetSummaryInformationW( IStorage *stg, UINT uiUpdateCount ); extern MSISUMMARYINFO *MSI_GetSummaryInformationW( IStorage *stg, UINT uiUpdateCount );
extern LPWSTR msi_suminfo_dup_string( MSISUMMARYINFO *si, UINT uiProperty ); extern LPWSTR msi_suminfo_dup_string( MSISUMMARYINFO *si, UINT uiProperty );
extern INT msi_suminfo_get_int32( MSISUMMARYINFO *si, UINT uiProperty );
extern LPWSTR msi_get_suminfo_product( IStorage *stg ); extern LPWSTR msi_get_suminfo_product( IStorage *stg );
extern UINT msi_add_suminfo( MSIDATABASE *db, LPWSTR **records, int num_records, int num_columns ); extern UINT msi_add_suminfo( MSIDATABASE *db, LPWSTR **records, int num_records, int num_columns );

View File

@ -1292,6 +1292,9 @@ static UINT msi_parse_summary( MSISUMMARYINFO *si, MSIPACKAGE *package )
WCHAR *template, *p, *q; WCHAR *template, *p, *q;
DWORD i, count; DWORD i, count;
package->version = msi_suminfo_get_int32( si, PID_PAGECOUNT );
TRACE("version: %d\n", package->version);
template = msi_suminfo_dup_string( si, PID_TEMPLATE ); template = msi_suminfo_dup_string( si, PID_TEMPLATE );
if (!template) if (!template)
return ERROR_SUCCESS; /* native accepts missing template property */ return ERROR_SUCCESS; /* native accepts missing template property */
@ -1316,7 +1319,7 @@ static UINT msi_parse_summary( MSISUMMARYINFO *si, MSIPACKAGE *package )
{ {
WARN("unknown platform %s\n", debugstr_w(template)); WARN("unknown platform %s\n", debugstr_w(template));
msi_free( template ); msi_free( template );
return ERROR_PATCH_PACKAGE_INVALID; return ERROR_INSTALL_PLATFORM_UNSUPPORTED;
} }
count = 1; count = 1;
@ -1345,6 +1348,32 @@ static UINT msi_parse_summary( MSISUMMARYINFO *si, MSIPACKAGE *package )
return ERROR_SUCCESS; return ERROR_SUCCESS;
} }
static UINT validate_package( MSIPACKAGE *package )
{
static const BOOL is_64bit = sizeof(void *) > sizeof(int);
BOOL is_wow64;
UINT i;
IsWow64Process( GetCurrentProcess(), &is_wow64 );
if (package->platform == PLATFORM_X64)
{
if (!is_64bit && !is_wow64)
return ERROR_INSTALL_PLATFORM_UNSUPPORTED;
if (package->version < 200)
return ERROR_INSTALL_PACKAGE_INVALID;
}
if (!package->num_langids)
{
return ERROR_SUCCESS;
}
for (i = 0; i < package->num_langids; i++)
{
if (!package->langids[i] || IsValidLocale( package->langids[i], LCID_INSTALLED ))
return ERROR_SUCCESS;
}
return ERROR_INSTALL_LANGUAGE_UNSUPPORTED;
}
UINT MSI_OpenPackageW(LPCWSTR szPackage, MSIPACKAGE **pPackage) UINT MSI_OpenPackageW(LPCWSTR szPackage, MSIPACKAGE **pPackage)
{ {
static const WCHAR Database[] = {'D','A','T','A','B','A','S','E',0}; static const WCHAR Database[] = {'D','A','T','A','B','A','S','E',0};
@ -1474,6 +1503,12 @@ UINT MSI_OpenPackageW(LPCWSTR szPackage, MSIPACKAGE **pPackage)
return r; return r;
} }
r = validate_package( package );
if (r != ERROR_SUCCESS)
{
msiobj_release( &package->hdr );
return r;
}
msi_set_property( package->db, Database, db->path ); msi_set_property( package->db, Database, db->path );
if( UrlIsW( szPackage, URLIS_URL ) ) if( UrlIsW( szPackage, URLIS_URL ) )

View File

@ -644,6 +644,18 @@ LPWSTR msi_suminfo_dup_string( MSISUMMARYINFO *si, UINT uiProperty )
return strdupAtoW( prop->u.pszVal ); return strdupAtoW( prop->u.pszVal );
} }
INT msi_suminfo_get_int32( MSISUMMARYINFO *si, UINT uiProperty )
{
PROPVARIANT *prop;
if ( uiProperty >= MSI_MAX_PROPS )
return -1;
prop = &si->property[uiProperty];
if( prop->vt != VT_I4 )
return -1;
return prop->u.lVal;
}
LPWSTR msi_get_suminfo_product( IStorage *stg ) LPWSTR msi_get_suminfo_product( IStorage *stg )
{ {
MSISUMMARYINFO *si; MSISUMMARYINFO *si;