msi: Fix NULL dereference in MsiQueryComponentStateW (coverity)
Nikolay Sivov
bunglehead at gmail.com
Sat Jan 24 08:06:40 CST 2009
Changelog:
- Fix NULL dereference in MsiQueryComponentStateW, test added
>From 417ffa5fcc23f3806fe1082e339c94bc5f482513 Mon Sep 17 00:00:00 2001
From: Nikolay Sivov <bunglehead at gmail.com>
Date: Sat, 24 Jan 2009 16:56:49 +0300
Subject: Fix NULL dereference in MsiQueryComponentStateW
---
dlls/msi/msi.c | 2 +-
dlls/msi/tests/msi.c | 6 ++++++
2 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/dlls/msi/msi.c b/dlls/msi/msi.c
index 86713fd..9503cf9 100644
--- a/dlls/msi/msi.c
+++ b/dlls/msi/msi.c
@@ -1553,7 +1553,7 @@ UINT WINAPI MsiQueryComponentStateW(LPCWSTR szProductCode,
TRACE("(%s, %s, %d, %s, %p)\n", debugstr_w(szProductCode),
debugstr_w(szUserSid), dwContext, debugstr_w(szComponent), pdwState);
- if (!pdwState)
+ if (!pdwState || !szComponent)
return ERROR_INVALID_PARAMETER;
if (!szProductCode || !*szProductCode || lstrlenW(szProductCode) != GUID_SIZE - 1)
diff --git a/dlls/msi/tests/msi.c b/dlls/msi/tests/msi.c
index 3ce1a0d..5fb4395 100644
--- a/dlls/msi/tests/msi.c
+++ b/dlls/msi/tests/msi.c
@@ -1278,6 +1278,12 @@ static void test_MsiQueryComponentState(void)
ok(state == INSTALLSTATE_NOTUSED || state == INSTALLSTATE_LOCAL,
"Expected INSTALLSTATE_NOTUSED or INSTALLSTATE_LOCAL, got %d\n", state);
+ /* NULL component, product exists */
+ state = MAGIC_ERROR;
+ r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, NULL, &state);
+ ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(state == MAGIC_ERROR, "Expected state not changed, got %d\n", state);
+
res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"hi", 2);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
--
1.5.6.5
More information about the wine-patches
mailing list