[PATCH 5/6] msi: Handle some invalid parameters in MsiGetFeatureCost().
Zebediah Figura
z.figura12 at gmail.com
Tue Apr 24 22:27:41 CDT 2018
Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
dlls/msi/install.c | 9 +++++++++
dlls/msi/tests/package.c | 18 ++++++++++++++++--
2 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/dlls/msi/install.c b/dlls/msi/install.c
index b9290b4..63aed1e 100644
--- a/dlls/msi/install.c
+++ b/dlls/msi/install.c
@@ -1061,6 +1061,9 @@ UINT WINAPI MsiGetFeatureCostW(MSIHANDLE hInstall, LPCWSTR szFeature,
TRACE("(%d %s %i %i %p)\n", hInstall, debugstr_w(szFeature),
iCostTree, iState, piCost);
+ if (!szFeature)
+ return ERROR_INVALID_PARAMETER;
+
package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE);
if (!package)
{
@@ -1090,6 +1093,12 @@ UINT WINAPI MsiGetFeatureCostW(MSIHANDLE hInstall, LPCWSTR szFeature,
return ERROR_SUCCESS;
}
+ if (!piCost)
+ {
+ msiobj_release( &package->hdr );
+ return ERROR_INVALID_PARAMETER;
+ }
+
feature = msi_get_loaded_feature(package, szFeature);
if (feature)
diff --git a/dlls/msi/tests/package.c b/dlls/msi/tests/package.c
index c2e2106..d26e2fd 100644
--- a/dlls/msi/tests/package.c
+++ b/dlls/msi/tests/package.c
@@ -8479,7 +8479,7 @@ static void test_MsiApplyPatch(void)
ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
}
-static void test_MsiEnumComponentCosts(void)
+static void test_costs(void)
{
MSIHANDLE hdb, hpkg;
char package[12], drive[3];
@@ -8662,6 +8662,20 @@ static void test_MsiEnumComponentCosts(void)
r = MsiEnumComponentCostsA( hpkg, "", 1, INSTALLSTATE_UNKNOWN, drive, &len, &cost, &temp );
ok( r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %u\n", r );
+ /* test MsiGetFeatureCost */
+ cost = 0xdead;
+ r = MsiGetFeatureCostA( hpkg, NULL, MSICOSTTREE_SELFONLY, INSTALLSTATE_LOCAL, &cost );
+ ok( r == ERROR_INVALID_PARAMETER, "got %u\n", r);
+ ok( cost == 0xdead, "got %d\n", cost );
+
+ r = MsiGetFeatureCostA( hpkg, "one", MSICOSTTREE_SELFONLY, INSTALLSTATE_LOCAL, NULL );
+ ok( r == ERROR_INVALID_PARAMETER, "got %u\n", r);
+
+ cost = 0xdead;
+ r = MsiGetFeatureCostA( hpkg, "one", MSICOSTTREE_SELFONLY, INSTALLSTATE_LOCAL, &cost );
+ ok( !r, "got %u\n", r);
+ ok( cost == 8, "got %d\n", cost );
+
MsiCloseHandle( hpkg );
error:
MsiCloseHandle( hdb );
@@ -9702,7 +9716,7 @@ START_TEST(package)
test_MsiSetProperty();
test_MsiApplyMultiplePatches();
test_MsiApplyPatch();
- test_MsiEnumComponentCosts();
+ test_costs();
test_MsiDatabaseCommit();
test_externalui();
test_externalui_message();
--
2.7.4
More information about the wine-devel
mailing list