From 4ee1745e8152c1fd9756e5e632f428d3572d3892 Mon Sep 17 00:00:00 2001 From: James Hawkins Date: Tue, 19 Feb 2008 02:11:42 -0600 Subject: [PATCH] msi: Validate the dwOptions parameter of MsiSourceListSetInfo. --- dlls/msi/source.c | 7 ++++++ dlls/msi/tests/source.c | 49 +++++++++++++---------------------------- 2 files changed, 22 insertions(+), 34 deletions(-) diff --git a/dlls/msi/source.c b/dlls/msi/source.c index 9702cdaaea3..737c8cff7d2 100644 --- a/dlls/msi/source.c +++ b/dlls/msi/source.c @@ -435,6 +435,13 @@ UINT WINAPI MsiSourceListSetInfoW( LPCWSTR szProduct, LPCWSTR szUserSid, if (rc != ERROR_SUCCESS) return rc; + if (lstrcmpW(szProperty, INSTALLPROPERTY_LASTUSEDSOURCEW) && + dwOptions & (MSISOURCETYPE_NETWORK | MSISOURCETYPE_URL)) + { + RegCloseKey(sourcekey); + return ERROR_INVALID_PARAMETER; + } + if (!lstrcmpW(szProperty, INSTALLPROPERTY_MEDIAPACKAGEPATHW) || !lstrcmpW(szProperty, INSTALLPROPERTY_DISKPROMPTW)) { diff --git a/dlls/msi/tests/source.c b/dlls/msi/tests/source.c index ffc2145936b..b2e88eeb4cf 100644 --- a/dlls/msi/tests/source.c +++ b/dlls/msi/tests/source.c @@ -1452,16 +1452,15 @@ static void test_MsiSourceListSetInfo(void) r = MsiSourceListSetInfoA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED, MSICODE_PATCH, INSTALLPROPERTY_MEDIAPACKAGEPATH, "path"); - ok(r == ERROR_UNKNOWN_PATCH, - "Expected ERROR_UNKNOWN_PATCH, got %d\n", r); + ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r); /* dwOptions is both MSICODE_PRODUCT and MSICODE_PATCH */ r = MsiSourceListSetInfoA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED, MSICODE_PRODUCT | MSICODE_PATCH | MSISOURCETYPE_URL, INSTALLPROPERTY_MEDIAPACKAGEPATH, "path"); - ok(r == ERROR_UNKNOWN_PATCH, - "Expected ERROR_SUCCESS, got %d\n", r); + ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r); + /* dwOptions has both MSISOURCETYPE_NETWORK and MSISOURCETYPE_URL */ r = MsiSourceListSetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, @@ -1556,22 +1555,16 @@ static void test_MsiSourceListSetInfo(void) MSIINSTALLCONTEXT_USERUNMANAGED, MSICODE_PRODUCT | MSISOURCETYPE_NETWORK, INSTALLPROPERTY_MEDIAPACKAGEPATH, "path"); - todo_wine - { - ok(r == ERROR_INVALID_PARAMETER, - "Expected ERROR_INVALID_PARAMETER, got %d\n", r); - } + ok(r == ERROR_INVALID_PARAMETER, + "Expected ERROR_INVALID_PARAMETER, got %d\n", r); /* INSTALLPROPERTY_MEDIAPACKAGEPATH, MSISOURCETYPE_URL */ r = MsiSourceListSetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, MSICODE_PRODUCT | MSISOURCETYPE_URL, INSTALLPROPERTY_MEDIAPACKAGEPATH, "path"); - todo_wine - { - ok(r == ERROR_INVALID_PARAMETER, - "Expected ERROR_INVALID_PARAMETER, got %d\n", r); - } + ok(r == ERROR_INVALID_PARAMETER, + "Expected ERROR_INVALID_PARAMETER, got %d\n", r); /* INSTALLPROPERTY_DISKPROMPT */ r = MsiSourceListSetInfoA(prodcode, NULL, @@ -1585,22 +1578,16 @@ static void test_MsiSourceListSetInfo(void) MSIINSTALLCONTEXT_USERUNMANAGED, MSICODE_PRODUCT | MSISOURCETYPE_NETWORK, INSTALLPROPERTY_DISKPROMPT, "prompt"); - todo_wine - { - ok(r == ERROR_INVALID_PARAMETER, - "Expected ERROR_INVALID_PARAMETER, got %d\n", r); - } + ok(r == ERROR_INVALID_PARAMETER, + "Expected ERROR_INVALID_PARAMETER, got %d\n", r); /* INSTALLPROPERTY_DISKPROMPT, MSISOURCETYPE_URL */ r = MsiSourceListSetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, MSICODE_PRODUCT | MSISOURCETYPE_URL, INSTALLPROPERTY_DISKPROMPT, "prompt"); - todo_wine - { - ok(r == ERROR_INVALID_PARAMETER, - "Expected ERROR_INVALID_PARAMETER, got %d\n", r); - } + ok(r == ERROR_INVALID_PARAMETER, + "Expected ERROR_INVALID_PARAMETER, got %d\n", r); /* INSTALLPROPERTY_LASTUSEDSOURCE */ r = MsiSourceListSetInfoA(prodcode, NULL, @@ -1664,22 +1651,16 @@ static void test_MsiSourceListSetInfo(void) MSIINSTALLCONTEXT_USERUNMANAGED, MSICODE_PRODUCT | MSISOURCETYPE_NETWORK, INSTALLPROPERTY_PACKAGENAME, "name"); - todo_wine - { - ok(r == ERROR_INVALID_PARAMETER, - "Expected ERROR_INVALID_PARAMETER, got %d\n", r); - } + ok(r == ERROR_INVALID_PARAMETER, + "Expected ERROR_INVALID_PARAMETER, got %d\n", r); /* INSTALLPROPERTY_PACKAGENAME, MSISOURCETYPE_URL */ r = MsiSourceListSetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, MSICODE_PRODUCT | MSISOURCETYPE_URL, INSTALLPROPERTY_PACKAGENAME, "name"); - todo_wine - { - ok(r == ERROR_INVALID_PARAMETER, - "Expected ERROR_INVALID_PARAMETER, got %d\n", r); - } + ok(r == ERROR_INVALID_PARAMETER, + "Expected ERROR_INVALID_PARAMETER, got %d\n", r); /* INSTALLPROPERTY_LASTUSEDTYPE */ r = MsiSourceListSetInfoA(prodcode, NULL,