Commit ce6e84c0 authored by James Hawkins's avatar James Hawkins Committed by Alexandre Julliard

msi: Verify that the PID_PAGECOUNT and PID_REVNUMBER summary info properties exist.

parent 620862e3
...@@ -637,7 +637,7 @@ static UINT msi_load_summary_properties( MSIPACKAGE *package ) ...@@ -637,7 +637,7 @@ static UINT msi_load_summary_properties( MSIPACKAGE *package )
UINT rc; UINT rc;
MSIHANDLE suminfo; MSIHANDLE suminfo;
MSIHANDLE hdb = alloc_msihandle( &package->db->hdr ); MSIHANDLE hdb = alloc_msihandle( &package->db->hdr );
INT word_count; INT count;
DWORD len; DWORD len;
LPWSTR package_code; LPWSTR package_code;
static const WCHAR szPackageCode[] = { static const WCHAR szPackageCode[] = {
...@@ -645,8 +645,9 @@ static UINT msi_load_summary_properties( MSIPACKAGE *package ) ...@@ -645,8 +645,9 @@ static UINT msi_load_summary_properties( MSIPACKAGE *package )
if (!hdb) { if (!hdb) {
ERR("Unable to allocate handle\n"); ERR("Unable to allocate handle\n");
return 0; return ERROR_OUTOFMEMORY;
} }
rc = MsiGetSummaryInformationW( hdb, NULL, 0, &suminfo ); rc = MsiGetSummaryInformationW( hdb, NULL, 0, &suminfo );
MsiCloseHandle(hdb); MsiCloseHandle(hdb);
if (rc != ERROR_SUCCESS) if (rc != ERROR_SUCCESS)
...@@ -655,35 +656,47 @@ static UINT msi_load_summary_properties( MSIPACKAGE *package ) ...@@ -655,35 +656,47 @@ static UINT msi_load_summary_properties( MSIPACKAGE *package )
return rc; return rc;
} }
/* load package attributes */ rc = MsiSummaryInfoGetPropertyW( suminfo, PID_PAGECOUNT, NULL,
rc = MsiSummaryInfoGetPropertyW( suminfo, PID_WORDCOUNT, NULL, &count, NULL, NULL, NULL );
&word_count, NULL, NULL, NULL ); if (rc != ERROR_SUCCESS)
if (rc == ERROR_SUCCESS) {
package->WordCount = word_count; WARN("Unable to query page count: %d", rc);
else goto done;
WARN("Unable to query word count\n"); }
/* load package code property */ /* load package code property */
len = 0; len = 0;
rc = MsiSummaryInfoGetPropertyW( suminfo, PID_REVNUMBER, NULL, rc = MsiSummaryInfoGetPropertyW( suminfo, PID_REVNUMBER, NULL,
NULL, NULL, NULL, &len ); NULL, NULL, NULL, &len );
if (rc == ERROR_MORE_DATA) if (rc != ERROR_MORE_DATA)
{ {
WARN("Unable to query revision number: %d\n", rc);
rc = ERROR_FUNCTION_FAILED;
goto done;
}
len++; len++;
package_code = msi_alloc( len * sizeof(WCHAR) ); package_code = msi_alloc( len * sizeof(WCHAR) );
rc = MsiSummaryInfoGetPropertyW( suminfo, PID_REVNUMBER, NULL, rc = MsiSummaryInfoGetPropertyW( suminfo, PID_REVNUMBER, NULL,
NULL, NULL, package_code, &len ); NULL, NULL, package_code, &len );
if (rc == ERROR_SUCCESS) if (rc != ERROR_SUCCESS)
{
WARN("Unable to query rev number: %d\n", rc);
goto done;
}
MSI_SetPropertyW( package, szPackageCode, package_code ); MSI_SetPropertyW( package, szPackageCode, package_code );
else
WARN("Unable to query rev number, %d\n", rc);
msi_free( package_code ); msi_free( package_code );
}
else
WARN("Unable to query rev number, %d\n", rc);
/* load package attributes */
count = 0;
MsiSummaryInfoGetPropertyW( suminfo, PID_WORDCOUNT, NULL,
&count, NULL, NULL, NULL );
package->WordCount = count;
done:
MsiCloseHandle(suminfo); MsiCloseHandle(suminfo);
return ERROR_SUCCESS; return rc;
} }
static MSIPACKAGE *msi_alloc_package( void ) static MSIPACKAGE *msi_alloc_package( void )
...@@ -746,6 +759,7 @@ MSIPACKAGE *MSI_CreatePackage( MSIDATABASE *db, LPCWSTR base_url ) ...@@ -746,6 +759,7 @@ MSIPACKAGE *MSI_CreatePackage( MSIDATABASE *db, LPCWSTR base_url )
'P','r','o','d','u','c','t','C','o','d','e',0}; 'P','r','o','d','u','c','t','C','o','d','e',0};
MSIPACKAGE *package; MSIPACKAGE *package;
WCHAR uilevel[10]; WCHAR uilevel[10];
UINT r;
TRACE("%p\n", db); TRACE("%p\n", db);
...@@ -767,7 +781,12 @@ MSIPACKAGE *MSI_CreatePackage( MSIDATABASE *db, LPCWSTR base_url ) ...@@ -767,7 +781,12 @@ MSIPACKAGE *MSI_CreatePackage( MSIDATABASE *db, LPCWSTR base_url )
package->ProductCode = msi_dup_property( package, szProductCode ); package->ProductCode = msi_dup_property( package, szProductCode );
set_installed_prop( package ); set_installed_prop( package );
msi_load_summary_properties( package ); r = msi_load_summary_properties( package );
if (r != ERROR_SUCCESS)
{
msiobj_release( &package->hdr );
return NULL;
}
if (package->WordCount & MSIWORDCOUNT_ADMINISTRATIVE) if (package->WordCount & MSIWORDCOUNT_ADMINISTRATIVE)
msi_load_admin_properties( package ); msi_load_admin_properties( package );
...@@ -906,7 +925,8 @@ UINT MSI_OpenPackageW(LPCWSTR szPackage, MSIPACKAGE **pPackage) ...@@ -906,7 +925,8 @@ UINT MSI_OpenPackageW(LPCWSTR szPackage, MSIPACKAGE **pPackage)
{ {
if (file != szPackage) if (file != szPackage)
DeleteFileW( file ); DeleteFileW( file );
return ERROR_FUNCTION_FAILED;
return ERROR_INSTALL_PACKAGE_INVALID;
} }
if( file != szPackage ) if( file != szPackage )
......
...@@ -2045,6 +2045,7 @@ static void test_msipackage(void) ...@@ -2045,6 +2045,7 @@ static void test_msipackage(void)
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
} }
if (r == ERROR_SUCCESS)
MsiCloseHandle(hpack); MsiCloseHandle(hpack);
/* nonexistent szPackagePath */ /* nonexistent szPackagePath */
...@@ -2066,14 +2067,8 @@ static void test_msipackage(void) ...@@ -2066,14 +2067,8 @@ static void test_msipackage(void)
/* database exists, but is emtpy */ /* database exists, but is emtpy */
sprintf(name, "#%ld", hdb); sprintf(name, "#%ld", hdb);
r = MsiOpenPackage(name, &hpack); r = MsiOpenPackage(name, &hpack);
todo_wine
{
ok(r == ERROR_INSTALL_PACKAGE_INVALID, ok(r == ERROR_INSTALL_PACKAGE_INVALID,
"Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r); "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
}
if (r == ERROR_SUCCESS)
MsiCloseHandle(hpack);
query = "CREATE TABLE `Property` ( " query = "CREATE TABLE `Property` ( "
"`Property` CHAR(72), `Value` CHAR(0) " "`Property` CHAR(72), `Value` CHAR(0) "
...@@ -2090,14 +2085,8 @@ static void test_msipackage(void) ...@@ -2090,14 +2085,8 @@ static void test_msipackage(void)
/* a few key tables exist */ /* a few key tables exist */
sprintf(name, "#%ld", hdb); sprintf(name, "#%ld", hdb);
r = MsiOpenPackage(name, &hpack); r = MsiOpenPackage(name, &hpack);
todo_wine
{
ok(r == ERROR_INSTALL_PACKAGE_INVALID, ok(r == ERROR_INSTALL_PACKAGE_INVALID,
"Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r); "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
}
if (r == ERROR_SUCCESS)
MsiCloseHandle(hpack);
MsiCloseHandle(hdb); MsiCloseHandle(hdb);
DeleteFile(msifile); DeleteFile(msifile);
...@@ -2115,14 +2104,8 @@ static void test_msipackage(void) ...@@ -2115,14 +2104,8 @@ static void test_msipackage(void)
set_summary_dword(hdb, PID_PAGECOUNT, 100); set_summary_dword(hdb, PID_PAGECOUNT, 100);
r = MsiOpenPackage(name, &hpack); r = MsiOpenPackage(name, &hpack);
todo_wine
{
ok(r == ERROR_INSTALL_PACKAGE_INVALID, ok(r == ERROR_INSTALL_PACKAGE_INVALID,
"Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r); "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
}
if (r == ERROR_SUCCESS)
MsiCloseHandle(hpack);
set_summary_str(hdb, PID_REVNUMBER, "{004757CD-5092-49c2-AD20-28E1CE0DF5F2}"); set_summary_str(hdb, PID_REVNUMBER, "{004757CD-5092-49c2-AD20-28E1CE0DF5F2}");
r = MsiOpenPackage(name, &hpack); r = MsiOpenPackage(name, &hpack);
......
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