[3/7] msi: Validate packages based on supported version, platform and languages.
Hans Leidekker
hans at codeweavers.com
Wed Oct 6 08:44:08 CDT 2010
---
dlls/msi/msipriv.h | 2 ++
dlls/msi/package.c | 37 ++++++++++++++++++++++++++++++++++++-
dlls/msi/suminfo.c | 12 ++++++++++++
3 files changed, 50 insertions(+), 1 deletions(-)
diff --git a/dlls/msi/msipriv.h b/dlls/msi/msipriv.h
index 9149aa6..bff9990 100644
--- a/dlls/msi/msipriv.h
+++ b/dlls/msi/msipriv.h
@@ -315,6 +315,7 @@ typedef struct tagMSIPACKAGE
{
MSIOBJECTHDR hdr;
MSIDATABASE *db;
+ INT version;
enum platform platform;
UINT num_langids;
LANGID *langids;
@@ -855,6 +856,7 @@ extern UINT msi_spawn_error_dialog( MSIPACKAGE*, LPWSTR, LPWSTR );
/* summary information */
extern MSISUMMARYINFO *MSI_GetSummaryInformationW( IStorage *stg, UINT uiUpdateCount );
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 UINT msi_add_suminfo( MSIDATABASE *db, LPWSTR **records, int num_records, int num_columns );
diff --git a/dlls/msi/package.c b/dlls/msi/package.c
index 2b44e64..cd1cdf8 100644
--- a/dlls/msi/package.c
+++ b/dlls/msi/package.c
@@ -1292,6 +1292,9 @@ static UINT msi_parse_summary( MSISUMMARYINFO *si, MSIPACKAGE *package )
WCHAR *template, *p, *q;
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 );
if (!template)
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));
msi_free( template );
- return ERROR_PATCH_PACKAGE_INVALID;
+ return ERROR_INSTALL_PLATFORM_UNSUPPORTED;
}
count = 1;
@@ -1345,6 +1348,32 @@ static UINT msi_parse_summary( MSISUMMARYINFO *si, MSIPACKAGE *package )
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)
{
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;
}
+ r = validate_package( package );
+ if (r != ERROR_SUCCESS)
+ {
+ msiobj_release( &package->hdr );
+ return r;
+ }
msi_set_property( package->db, Database, db->path );
if( UrlIsW( szPackage, URLIS_URL ) )
diff --git a/dlls/msi/suminfo.c b/dlls/msi/suminfo.c
index b174e5b..2a9cd71 100644
--- a/dlls/msi/suminfo.c
+++ b/dlls/msi/suminfo.c
@@ -644,6 +644,18 @@ LPWSTR msi_suminfo_dup_string( MSISUMMARYINFO *si, UINT uiProperty )
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 )
{
MSISUMMARYINFO *si;
--
1.7.1
More information about the wine-patches
mailing list