From f83d0498881e1eb051c7bb47139fd595002b08b0 Mon Sep 17 00:00:00 2001 From: James Hawkins Date: Tue, 19 Feb 2008 02:08:11 -0600 Subject: [PATCH] msi: Validate the szProduct parameter of MsiSourceListSetInfo. --- dlls/msi/source.c | 3 ++- dlls/msi/tests/source.c | 22 ++++++---------------- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/dlls/msi/source.c b/dlls/msi/source.c index 03b8b61a918..887c702f7f9 100644 --- a/dlls/msi/source.c +++ b/dlls/msi/source.c @@ -394,13 +394,14 @@ UINT WINAPI MsiSourceListSetInfoW( LPCWSTR szProduct, LPCWSTR szUserSid, MSIINSTALLCONTEXT dwContext, DWORD dwOptions, LPCWSTR szProperty, LPCWSTR szValue) { + WCHAR squished_pc[GUID_SIZE]; HKEY sourcekey; UINT rc; TRACE("%s %s %x %x %s %s\n", debugstr_w(szProduct), debugstr_w(szUserSid), dwContext, dwOptions, debugstr_w(szProperty), debugstr_w(szValue)); - if (!szProduct || lstrlenW(szProduct) > 39) + if (!szProduct || !squash_guid(szProduct, squished_pc)) return ERROR_INVALID_PARAMETER; if (!szProperty) diff --git a/dlls/msi/tests/source.c b/dlls/msi/tests/source.c index 8028de34a47..90d4b0cfb8b 100644 --- a/dlls/msi/tests/source.c +++ b/dlls/msi/tests/source.c @@ -1398,7 +1398,6 @@ static void test_MsiSourceListSetInfo(void) LONG res; UINT r; - create_test_guid(prodcode, prod_squashed); get_user_sid(&usersid); @@ -1415,33 +1414,24 @@ static void test_MsiSourceListSetInfo(void) r = MsiSourceListSetInfoA("", usersid, 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); /* garbage szProductCodeOrPatchCode */ r = MsiSourceListSetInfoA("garbage", usersid, 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); /* guid without brackets */ r = MsiSourceListSetInfoA("51CD2AD5-0482-4C46-8DDD-0ED1022AA1AA", usersid, 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); /* guid with brackets */ r = MsiSourceListSetInfoA("{51CD2AD5-0482-4C46-8DDD-0ED1022AA1AA}",