James Hawkins : msi: Handle a NULL and empty szPackagePath in MsiInstallProduct (Coverity 181).

Alexandre Julliard julliard at winehq.org
Mon Mar 23 12:34:55 CDT 2009


Module: wine
Branch: master
Commit: 5e62686a0f9417248b9002a65699867a63358bfb
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=5e62686a0f9417248b9002a65699867a63358bfb

Author: James Hawkins <truiken at gmail.com>
Date:   Sun Mar 22 14:31:35 2009 -0700

msi: Handle a NULL and empty szPackagePath in MsiInstallProduct (Coverity 181).

---

 dlls/msi/msi.c           |    6 ++++++
 dlls/msi/tests/install.c |   15 +++++++++++++++
 2 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/dlls/msi/msi.c b/dlls/msi/msi.c
index 7cca153..be1eafd 100644
--- a/dlls/msi/msi.c
+++ b/dlls/msi/msi.c
@@ -231,6 +231,12 @@ UINT WINAPI MsiInstallProductW(LPCWSTR szPackagePath, LPCWSTR szCommandLine)
 
     TRACE("%s %s\n",debugstr_w(szPackagePath), debugstr_w(szCommandLine));
 
+    if (!szPackagePath)
+        return ERROR_INVALID_PARAMETER;
+
+    if (!*szPackagePath)
+        return ERROR_PATH_NOT_FOUND;
+
     r = MSI_OpenPackageW( szPackagePath, &package );
     if (r == ERROR_SUCCESS)
     {
diff --git a/dlls/msi/tests/install.c b/dlls/msi/tests/install.c
index f0ee296..a844395 100644
--- a/dlls/msi/tests/install.c
+++ b/dlls/msi/tests/install.c
@@ -1721,6 +1721,21 @@ static void test_MsiInstallProduct(void)
         return;
     }
 
+    /* szPackagePath is NULL */
+    r = MsiInstallProductA(NULL, "INSTALL=ALL");
+    ok(r == ERROR_INVALID_PARAMETER,
+       "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
+
+    /* both szPackagePath and szCommandLine are NULL */
+    r = MsiInstallProductA(NULL, NULL);
+    ok(r == ERROR_INVALID_PARAMETER,
+       "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
+
+    /* szPackagePath is empty */
+    r = MsiInstallProductA("", "INSTALL=ALL");
+    ok(r == ERROR_PATH_NOT_FOUND,
+       "Expected ERROR_PATH_NOT_FOUND, got %d\n", r);
+
     create_test_files();
     create_database(msifile, tables, sizeof(tables) / sizeof(msi_table));
 




More information about the wine-cvs mailing list