From 5e62686a0f9417248b9002a65699867a63358bfb Mon Sep 17 00:00:00 2001 From: James Hawkins Date: Sun, 22 Mar 2009 14:31:35 -0700 Subject: [PATCH] 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(+) diff --git a/dlls/msi/msi.c b/dlls/msi/msi.c index 7cca153f3f3..be1eafdb01f 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 f0ee2963720..a8443958461 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));