https://git.reactos.org/?p=reactos.git;a=commitdiff;h=818a84dd11866d3cd17d6…
commit 818a84dd11866d3cd17d684c4a6235e64e24526a
Author: winesync <ros-dev(a)reactos.org>
AuthorDate: Sat Mar 12 15:12:06 2022 +0100
Commit: Mark Jansen <mark.jansen(a)reactos.org>
CommitDate: Sun Mar 20 19:27:41 2022 +0100
[WINESYNC] msi: Handle some invalid parameters in MsiGetFeatureCost().
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com>
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
wine commit id 1b6adcb7216a6b4a0706ac7255f3ddb832656127 by Zebediah Figura
<z.figura12(a)gmail.com>
---
dll/win32/msi/install.c | 9 +++++++++
modules/rostests/winetests/msi/package.c | 18 ++++++++++++++++--
2 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/dll/win32/msi/install.c b/dll/win32/msi/install.c
index b9290b4a8d0..63aed1eeebe 100644
--- a/dll/win32/msi/install.c
+++ b/dll/win32/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/modules/rostests/winetests/msi/package.c
b/modules/rostests/winetests/msi/package.c
index c2e2106c38b..d26e2fdb56f 100644
--- a/modules/rostests/winetests/msi/package.c
+++ b/modules/rostests/winetests/msi/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();