msi: Validate MsiQueryProductCode parameters.

This commit is contained in:
James Hawkins 2007-06-26 16:30:40 -07:00 committed by Alexandre Julliard
parent db318ec9af
commit e92f66558a
2 changed files with 9 additions and 15 deletions

View File

@ -764,13 +764,16 @@ INSTALLSTATE WINAPI MsiQueryProductStateW(LPCWSTR szProduct)
UINT rc; UINT rc;
INSTALLSTATE rrc = INSTALLSTATE_UNKNOWN; INSTALLSTATE rrc = INSTALLSTATE_UNKNOWN;
HKEY hkey = 0; 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; 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)); TRACE("%s\n", debugstr_w(szProduct));
if (!szProduct) if (!szProduct || !*szProduct || lstrlenW(szProduct) != GUID_LEN)
return INSTALLSTATE_INVALIDARG; return INSTALLSTATE_INVALIDARG;
rc = MSIREG_OpenUserProductsKey(szProduct,&hkey,FALSE); rc = MSIREG_OpenUserProductsKey(szProduct,&hkey,FALSE);

View File

@ -347,24 +347,15 @@ static void test_MsiQueryProductState(void)
/* empty prodcode */ /* empty prodcode */
state = MsiQueryProductStateA(""); 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 */ /* garbage prodcode */
state = MsiQueryProductStateA("garbage"); 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 */ /* guid without brackets */
state = MsiQueryProductStateA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D"); 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 */ /* guid with brackets */
state = MsiQueryProductStateA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}"); state = MsiQueryProductStateA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}");