From e92f66558a8f415cee051d8752438726dbd64bc1 Mon Sep 17 00:00:00 2001 From: James Hawkins Date: Tue, 26 Jun 2007 16:30:40 -0700 Subject: [PATCH] msi: Validate MsiQueryProductCode parameters. --- dlls/msi/msi.c | 9 ++++++--- dlls/msi/tests/msi.c | 15 +++------------ 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/dlls/msi/msi.c b/dlls/msi/msi.c index 2042695ef6..05d3bbffa2 100644 --- a/dlls/msi/msi.c +++ b/dlls/msi/msi.c @@ -764,13 +764,16 @@ INSTALLSTATE WINAPI MsiQueryProductStateW(LPCWSTR szProduct) UINT rc; INSTALLSTATE rrc = INSTALLSTATE_UNKNOWN; HKEY hkey = 0; - static const WCHAR szWindowsInstaller[] = { - 'W','i','n','d','o','w','s','I','n','s','t','a','l','l','e','r',0 }; DWORD sz; + static const int GUID_LEN = 38; + static const WCHAR szWindowsInstaller[] = { + 'W','i','n','d','o','w','s','I','n','s','t','a','l','l','e','r',0 + }; + TRACE("%s\n", debugstr_w(szProduct)); - if (!szProduct) + if (!szProduct || !*szProduct || lstrlenW(szProduct) != GUID_LEN) return INSTALLSTATE_INVALIDARG; rc = MSIREG_OpenUserProductsKey(szProduct,&hkey,FALSE); diff --git a/dlls/msi/tests/msi.c b/dlls/msi/tests/msi.c index d9058249df..06c7276f6a 100644 --- a/dlls/msi/tests/msi.c +++ b/dlls/msi/tests/msi.c @@ -347,24 +347,15 @@ static void test_MsiQueryProductState(void) /* empty prodcode */ state = MsiQueryProductStateA(""); - todo_wine - { - ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state); - } + ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state); /* garbage prodcode */ state = MsiQueryProductStateA("garbage"); - todo_wine - { - ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state); - } + ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state); /* guid without brackets */ state = MsiQueryProductStateA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D"); - todo_wine - { - ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state); - } + ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state); /* guid with brackets */ state = MsiQueryProductStateA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}"); -- 2.32.0.93.g670b81a890