From: Oliver Kurth Date: Wed, 10 Apr 2019 21:14:52 +0000 (-0700) Subject: InitiateFileTransferToGuest fails when uploading file to root directory X-Git-Tag: stable-11.0.0~147 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=13f457aa737d8bca27f09862cf2a45df8f4a425b;p=thirdparty%2Fopen-vm-tools.git InitiateFileTransferToGuest fails when uploading file to root directory 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. --- diff --git a/open-vm-tools/services/plugins/vix/vixTools.c b/open-vm-tools/services/plugins/vix/vixTools.c index 15b0a8bdf..5af754973 100644 --- a/open-vm-tools/services/plugins/vix/vixTools.c +++ b/open-vm-tools/services/plugins/vix/vixTools.c @@ -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();