James Hawkins : msi: Validate the parameters of MsiSourceListAddMediaDisk.
Alexandre Julliard
julliard at winehq.org
Mon Feb 25 06:51:23 CST 2008
Module: wine
Branch: master
Commit: 34d50c1e3e3721165dc8e96bbd889976ddaf9a40
URL: http://source.winehq.org/git/wine.git/?a=commit;h=34d50c1e3e3721165dc8e96bbd889976ddaf9a40
Author: James Hawkins <jhawkins at codeweavers.com>
Date: Sun Feb 24 20:07:21 2008 -0600
msi: Validate the parameters of MsiSourceListAddMediaDisk.
---
dlls/msi/source.c | 12 ++++++++-
dlls/msi/tests/source.c | 63 +++++++++++++---------------------------------
2 files changed, 29 insertions(+), 46 deletions(-)
diff --git a/dlls/msi/source.c b/dlls/msi/source.c
index b2a45b1..3ffa5d8 100644
--- a/dlls/msi/source.c
+++ b/dlls/msi/source.c
@@ -978,6 +978,7 @@ UINT WINAPI MsiSourceListAddMediaDiskW(LPCWSTR szProduct, LPCWSTR szUserSid,
HKEY mediakey;
UINT rc;
WCHAR szIndex[10];
+ WCHAR squished_pc[GUID_SIZE];
static const WCHAR fmt[] = {'%','i',0};
static const WCHAR disk_fmt[] = {'%','s',';','%','s',0};
static const WCHAR empty[1] = {0};
@@ -989,7 +990,16 @@ UINT WINAPI MsiSourceListAddMediaDiskW(LPCWSTR szProduct, LPCWSTR szUserSid,
debugstr_w(szUserSid), dwContext, dwOptions, dwDiskId,
debugstr_w(szVolumeLabel), debugstr_w(szDiskPrompt));
- if (!szProduct || lstrlenW(szProduct) > 39)
+ if (!szProduct || !squash_guid(szProduct, squished_pc))
+ return ERROR_INVALID_PARAMETER;
+
+ if (dwOptions != MSICODE_PRODUCT && dwOptions != MSICODE_PATCH)
+ return ERROR_INVALID_PARAMETER;
+
+ if ((szVolumeLabel && !*szVolumeLabel) || (szDiskPrompt && !*szDiskPrompt))
+ return ERROR_INVALID_PARAMETER;
+
+ if ((dwContext & MSIINSTALLCONTEXT_MACHINE) && szUserSid)
return ERROR_INVALID_PARAMETER;
if (dwOptions & MSICODE_PATCH)
diff --git a/dlls/msi/tests/source.c b/dlls/msi/tests/source.c
index c11b3f1..d2e3b02 100644
--- a/dlls/msi/tests/source.c
+++ b/dlls/msi/tests/source.c
@@ -1965,30 +1965,21 @@ static void test_MsiSourceListAddMediaDisk(void)
/* empty szProductCodeOrPatchCode */
r = MsiSourceListAddMediaDiskA("", usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
MSICODE_PRODUCT, 1, "label", "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);
/* garbage szProductCodeOrPatchCode */
r = MsiSourceListAddMediaDiskA("garbage", usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
MSICODE_PRODUCT, 1, "label", "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);
/* guid without brackets */
r = MsiSourceListAddMediaDiskA("51CD2AD5-0482-4C46-8DDD-0ED1022AA1AA",
usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
MSICODE_PRODUCT, 1, "label", "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);
/* guid with brackets */
r = MsiSourceListAddMediaDiskA("{51CD2AD5-0482-4C46-8DDD-0ED1022AA1AA}",
@@ -2002,33 +1993,24 @@ static void test_MsiSourceListAddMediaDisk(void)
usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
MSICODE_PRODUCT | MSISOURCETYPE_NETWORK,
1, "label", "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);
/* dwOptions has MSISOURCETYPE_URL */
r = MsiSourceListAddMediaDiskA("{51CD2AD5-0482-4C46-8DDD-0ED1022AA1AA}",
usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
MSICODE_PRODUCT | MSISOURCETYPE_URL,
1, "label", "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);
/* dwOptions has MSISOURCETYPE_MEDIA */
r = MsiSourceListAddMediaDiskA("{51CD2AD5-0482-4C46-8DDD-0ED1022AA1AA}",
usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
MSICODE_PRODUCT | MSISOURCETYPE_MEDIA,
1, "label", "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);
/* MSIINSTALLCONTEXT_USERUNMANAGED */
@@ -2119,11 +2101,8 @@ static void test_MsiSourceListAddMediaDisk(void)
r = MsiSourceListAddMediaDiskA(prodcode, usersid,
MSIINSTALLCONTEXT_USERUNMANAGED,
MSICODE_PRODUCT, 1, "etikett", "");
- 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);
/* update dwDiskId 1, szVolumeLable is NULL */
r = MsiSourceListAddMediaDiskA(prodcode, usersid,
@@ -2140,11 +2119,8 @@ static void test_MsiSourceListAddMediaDisk(void)
r = MsiSourceListAddMediaDiskA(prodcode, usersid,
MSIINSTALLCONTEXT_USERUNMANAGED,
MSICODE_PRODUCT, 1, "", "provoquer");
- 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);
/* szUserSid is NULL */
r = MsiSourceListAddMediaDiskA(prodcode, NULL,
@@ -2248,11 +2224,8 @@ static void test_MsiSourceListAddMediaDisk(void)
r = MsiSourceListAddMediaDiskA(prodcode, usersid,
MSIINSTALLCONTEXT_MACHINE,
MSICODE_PRODUCT, 1, "label", "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);
RegDeleteValueA(media, "1");
RegDeleteKeyA(media, "");
More information about the wine-cvs
mailing list