wine/dlls/msi tests/package.c install.c

Alexandre Julliard julliard at wine.codeweavers.com
Wed Nov 2 05:43:06 CST 2005


ChangeSet ID:	21042
CVSROOT:	/opt/cvs-commit
Module name:	wine
Changes by:	julliard at winehq.org	2005/11/02 05:43:05

Modified files:
	dlls/msi/tests : package.c 
	dlls/msi       : install.c 

Log message:
	Mike McCormack <mike at codeweavers.com>
	Fix parameter handling in MsiSetTargetPath, and add a test for it.

Patch: http://cvs.winehq.org/patch.py?id=21042

Old revision  New revision  Changes     Path
 1.7           1.8           +24 -0      wine/dlls/msi/tests/package.c
 1.18          1.19          +17 -26     wine/dlls/msi/install.c

Index: wine/dlls/msi/tests/package.c
diff -u -p wine/dlls/msi/tests/package.c:1.7 wine/dlls/msi/tests/package.c:1.8
--- wine/dlls/msi/tests/package.c:1.7	2 Nov 2005 11:43: 5 -0000
+++ wine/dlls/msi/tests/package.c	2 Nov 2005 11:43: 5 -0000
@@ -326,6 +326,29 @@ static void test_gettargetpath_bad(void)
     MsiCloseHandle( hpkg );
 }
 
+void test_settargetpath_bad(void)
+{
+    MSIHANDLE hpkg;
+    UINT r;
+
+    hpkg = package_from_db(create_package_db());
+    ok( hpkg, "failed to create package\n");
+
+    r = MsiSetTargetPath( 0, NULL, NULL );
+    ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
+
+    r = MsiSetTargetPath( 0, "boo", "C:\\bogusx" );
+    ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
+
+    r = MsiSetTargetPath( hpkg, "boo", NULL );
+    ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
+
+    r = MsiSetTargetPath( hpkg, "boo", "c:\\bogusx" );
+    ok( r == ERROR_DIRECTORY, "wrong return val\n");
+
+    MsiCloseHandle( hpkg );
+}
+
 void test_condition(void)
 {
     MSICONDITION r;
@@ -696,5 +719,6 @@ START_TEST(package)
     test_getsourcepath();
     test_doaction();
     test_gettargetpath_bad();
+    test_settargetpath_bad();
     test_props();
 }
Index: wine/dlls/msi/install.c
diff -u -p wine/dlls/msi/install.c:1.18 wine/dlls/msi/install.c:1.19
--- wine/dlls/msi/install.c:1.18	2 Nov 2005 11:43: 5 -0000
+++ wine/dlls/msi/install.c	2 Nov 2005 11:43: 5 -0000
@@ -296,31 +296,23 @@ UINT WINAPI MsiGetSourcePathW( MSIHANDLE
 /***********************************************************************
  * MsiSetTargetPathA  (MSI.@)
  */
-UINT WINAPI MsiSetTargetPathA(MSIHANDLE hInstall, LPCSTR szFolder, 
-                             LPCSTR szFolderPath)
+UINT WINAPI MsiSetTargetPathA( MSIHANDLE hInstall, LPCSTR szFolder,
+                               LPCSTR szFolderPath )
 {
-    LPWSTR szwFolder;
-    LPWSTR szwFolderPath;
-    UINT rc;
+    LPWSTR szwFolder = NULL, szwFolderPath = NULL;
+    UINT rc = ERROR_OUTOFMEMORY;
 
-    if (!szFolder)
-        return ERROR_FUNCTION_FAILED;
-    if (hInstall == 0)
-        return ERROR_FUNCTION_FAILED;
+    if ( !szFolder || !szFolderPath )
+        return ERROR_INVALID_PARAMETER;
 
     szwFolder = strdupAtoW(szFolder);
-    if (!szwFolder)
-        return ERROR_FUNCTION_FAILED; 
-
     szwFolderPath = strdupAtoW(szFolderPath);
-    if (!szwFolderPath)
-    {
-        msi_free(szwFolder);
-        return ERROR_FUNCTION_FAILED; 
-    }
+    if (!szwFolder || !szwFolderPath)
+        goto end;
 
-    rc = MsiSetTargetPathW(hInstall, szwFolder, szwFolderPath);
+    rc = MsiSetTargetPathW( hInstall, szwFolder, szwFolderPath );
 
+end:
     msi_free(szwFolder);
     msi_free(szwFolderPath);
 
@@ -342,12 +334,6 @@ UINT MSI_SetTargetPathW(MSIPACKAGE *pack
 
     TRACE("(%p %s %s)\n",package, debugstr_w(szFolder),debugstr_w(szFolderPath));
 
-    if (package==NULL)
-        return ERROR_INVALID_HANDLE;
-
-    if (szFolderPath[0]==0)
-        return ERROR_FUNCTION_FAILED;
-
     attrib = GetFileAttributesW(szFolderPath);
     if ( attrib != INVALID_FILE_ATTRIBUTES &&
           (!(attrib & FILE_ATTRIBUTE_DIRECTORY) ||
@@ -356,9 +342,8 @@ UINT MSI_SetTargetPathW(MSIPACKAGE *pack
         return ERROR_FUNCTION_FAILED;
 
     path = resolve_folder(package,szFolder,FALSE,FALSE,&folder);
-
     if (!path)
-        return ERROR_INVALID_PARAMETER;
+        return ERROR_DIRECTORY;
 
     if (attrib == INVALID_FILE_ATTRIBUTES)
     {
@@ -416,7 +401,13 @@ UINT WINAPI MsiSetTargetPathW(MSIHANDLE 
 
     TRACE("(%s %s)\n",debugstr_w(szFolder),debugstr_w(szFolderPath));
 
+    if ( !szFolder || !szFolderPath )
+        return ERROR_INVALID_PARAMETER;
+
     package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE);
+    if (!package)
+        return ERROR_INVALID_HANDLE;
+
     ret = MSI_SetTargetPathW( package, szFolder, szFolderPath );
     msiobj_release( &package->hdr );
     return ret;



More information about the wine-cvs mailing list