]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
InitiateFileTransferToGuest fails when uploading file to root directory
authorOliver Kurth <okurth@vmware.com>
Wed, 10 Apr 2019 21:14:52 +0000 (14:14 -0700)
committerOliver Kurth <okurth@vmware.com>
Wed, 10 Apr 2019 21:14:52 +0000 (14:14 -0700)
File upload to '/' on Linux fails the directory exists check.
This is caused by the file dirname being an empty string when parsed from
the guest file path name per the documented behavior of File_GetPathName.

The caller of File_GetPathName needs to handle the expected empty dirname
string when dealing with file path in the root ('/') filesystem on Linux.

Proposed fix is to replace the dirname string with the root path ('/') when:
A. dirname obtained from File_GetPathName call is an empty string AND
B. the original file path name starts with the path separator ('/') on
   Linux (or *nix like) GOSes

This allows for the directory checks to inspect the root folder before
proceeding with the file transfer.

open-vm-tools/services/plugins/vix/vixTools.c

index 15b0a8bdffe3226f012e266a22d834feb892f563..5af75497396c4d75fad4dc0392d3d398420fd191 100644 (file)
@@ -4990,6 +4990,17 @@ VixToolsInitiateFileTransferToGuest(VixCommandRequestHeader *requestMsg)  // IN
       goto abort;
    }
 
+#ifndef _WIN32
+   if ('\0' == *dirName && '/' == *guestPathName) {
+      /*
+       * dirName is empty and represents root directory
+       * For *nix like paths, changing dirName to '/'
+       */
+      free(dirName);
+      dirName = Util_SafeStrdup("/");
+   }
+#endif
+
    if (!File_IsDirectory(dirName)) {
 #ifdef _WIN32
       DWORD sysErr = GetLastError();