Oliver Kurth [Wed, 22 May 2019 20:09:36 +0000 (13:09 -0700)]
Pick up filesystem (fsType) name for Linux disks.
Building upon the OS Volume Disk Mapping changes added for Windows
guests, pick up and propogate the filesystem type for Linux disks.
Move fsType related code and declaration out of the _WIN32 specific
source code.
Diskwiper code (for Linux) modified to pass along filesystem type
obtained from the MNTINFO structure from the non-Windows guest.
Also passing along the mount point for device-based mapping to be done
in the guestInfo plugin.
Oliver Kurth [Wed, 8 May 2019 22:27:20 +0000 (15:27 -0700)]
Fix the 'procCmdName' attribute of process information.
* When listing down the processes, /proc/{PID}/cmdline file is read
and parsed to figure out the command name. While doing this parsing,
the terminating NUL character is not parsed. Due to this, if any
process doesn't have any command line arguments, the 'command name' is
retrieved as NULL.
Note: This issue doesn't happen if the cmdLine has any arguments.
Ex:
/usr/bin/vmtoolsd -> 'cmdName' is retrieved as NULL
/usr/bin/vmtoolsd -n vmusr -> 'cmdName' is retrieved properly as 'vmtoolsd'
* Fixed the code to include the trailing NUL character also while parsing.
Oliver Kurth [Wed, 8 May 2019 22:27:20 +0000 (15:27 -0700)]
Hgfs fuse Client: fix max name length setting for statvfs
Detected internally with Fedora 29 and reported in
https://github.com/vmware/open-vm-tools/issues/337,
the statvfs structure must provide a valid max name length field. Setting
to NAME_MAX. This allows the GUI Files application to create new folders
and rename existing ones correctly.
Oliver Kurth [Wed, 8 May 2019 22:27:19 +0000 (15:27 -0700)]
Fix copy/paste on Ubuntu 19.04 guest
Ubuntu 19.04 chooses Nautilus 3.32 as the default file browser. From
3.30, Nautilus checks mime type when pasting files from the clipboard,
and the target type is also changed to UTF8_STRING instead of
x-special/gnome-copied-files. To support Ubuntu 19.04, apply this
change into our guest code.
Oliver Kurth [Wed, 8 May 2019 22:27:19 +0000 (15:27 -0700)]
Add a comment in vmci_sockets.h about why a file handle is "leaked"
Let's add a comment in vmci_sockets.h explaining why we intentionally "leak"
a file handle in VMCISock_GetAFValueFd.
fd is intentionally left open when outFd is NULL. Closing it
will break applications running on Linux without a fixed AF for
vSockets. In such cases, the fd will be closed during cleanup when
the application exits.
Oliver Kurth [Wed, 8 May 2019 22:27:19 +0000 (15:27 -0700)]
Fix a trivial Coverity-reported memory leak.
If AuthLoadPAM doesn't find all the needed symbols from the pam
library, then dlclose the library, as is already done for
the same-named funtion in bora/lib/auth/authPosix.c.
Oliver Kurth [Wed, 8 May 2019 22:27:19 +0000 (15:27 -0700)]
Fix Coverity-reported double memory free errors.
Similar double memory free errors were reported in each of two
functions, VixToolsListAuthAliases and VixToolsListMappedAliases.
The fixes for each function are similar: be consistent in using
tmpBuf2 (renamed tmpBuf) as the pointer to the overall buffer being
computed and tmpBuf (renamed nextBuf) as the "next" version of the
buffer. Specifically, in the computation of recordBuf following exit
from the for loop, use the variable formerly known as tmpBuf2 rather
than the one formerly known as tmpBuf.
The variables were renamed in an attempt to distinguish more clearly
between them and how they are used. Also, with these changes in
place, it's evident that there's no need to free nextBuf in the abort
case and as a result its scope can be limited.
Oliver Kurth [Wed, 8 May 2019 22:27:18 +0000 (15:27 -0700)]
Fixes for few leaks and improved error handling.
Fix a memory leak detected by coverity scan. It is not critical,
but it is real in an error case when there is no end mark. While
fixing it, also enhanced code to handle different error cases
properly because we would want valid content to be decoded even
when there are invalid marks in the log file. Invalid log marks
are possible when vmware.log gets rotated in the middle of guest
logging.
While verifying the fix using valgrind, found a couple of more
leaks in panic and warning stubs. Addressed those as well.
Oliver Kurth [Tue, 30 Apr 2019 20:24:25 +0000 (13:24 -0700)]
Provide a shutdown function for users of the unicode library to free memory
allocated by Unicode_Init().
Most applications using the unicode library do not free related memory
since they are about to terminate. A Unicode_Shutdown() function is
provided which will explicitly free the memory allocated by Unicode_Init().
Oliver Kurth [Tue, 30 Apr 2019 20:24:25 +0000 (13:24 -0700)]
vm_basic_defs.h: include stddef.h
The stddef.h header has existed since C89. It includes interesting
things like an offsetof definition, and a definition of NULL.
Let's stop re-inventing this long-standardized header. Except
in vmkernel, where bogus __FreeBSD__ values break gcc's <stddef.h>.
(Detail: vmkernel networking likes to define __FreeBSD__ to empty
or 1, whereas ABI requires "FreeBSD major version".
This change is deliberately minimal as touching headers included
everywhere is inherently fragile. Further cleanups (like removing
vmw_offsetof) can be done in follow-up changes.
The stddef.h header is a 'freestanding' header, which means it's
part of the language and not a "system" header. It is thus safe
to include (modulo vmkernel-networking problem above).
bora-vmsoft/apps/vmtoolsbib/i18n.c: MsgLoadCatalog()
- Coverity reported memory leak when an error is encountered parsing a
line from a message catalog.
- Second memory leak on error missed.
bora-vmsoft/vgauth/common/i18n.c: MsgLoadCatalog()
- Coverity reported some dead code.
- Missed reporting memory leak when error is encountered parsing a
line from a message catalog.
Oliver Kurth [Tue, 30 Apr 2019 20:24:24 +0000 (13:24 -0700)]
Toolsd uses log.text RPC only when the useLogTextRpc is set to TRUE.
This allows the tools installer to start use the log.text RPC without
worrying about that toolsd has not completed the work of scrubbing its logs
for security and privacy issues.
Oliver Kurth [Tue, 30 Apr 2019 20:24:24 +0000 (13:24 -0700)]
Fix memory leak in SNEBuildHash function.
In a specific code path of the SNEBuildHash function, when the
environment variable is of the format VMWARE_*=[0|1], the value
is not freed. Fixed the memory leak.
Oliver Kurth [Wed, 10 Apr 2019 21:14:57 +0000 (14:14 -0700)]
Remove use of "-Wno-address-of-packed-member" option for OVT builds on FBSD
With the HGFS source code refactor to avoid taking the address of a
packed structure memberuse of "-Wno-address-of-packed-member"
is no longer needed to build OVT on FBSD 11.x and FBSD 12.x.
Oliver Kurth [Wed, 10 Apr 2019 21:14:56 +0000 (14:14 -0700)]
Add a 64 bit pseudo random number generator
This change adds a 64 bit pseudo random number generator to the public
library by calling the existing 32 bit Random_Fast function twice.
Since the period of Random_Fast is 2^64, this should be sufficient.
Oliver Kurth [Wed, 10 Apr 2019 21:14:56 +0000 (14:14 -0700)]
Remove some "always TRUE" comparisons reported by clang 6.0 on FBSD.
A recent refactoring of HGFS fuse code to avoid taking the address of
a field in a packed structure introduced a comparision of an array
address != NULL which will always evaluate to "true". Removing the
unnecessary "if" statements.
Oliver Kurth [Wed, 10 Apr 2019 21:14:55 +0000 (14:14 -0700)]
DnD Phase II] - Avoid potential memory overflow.
In the case when dragging a format whose size is exactly the same as the
size threshold and plain text is provided, the plain text can't be added.
Current logic does not handle this case. Instead it will result in a
large unsigned number (0-1 = 0xffff_ffff) of bytes to be allocated to
store plain text which causes memory overflow.
Just return in the case that no more size left to add plain text or the
plain text is empty.
Oliver Kurth [Wed, 10 Apr 2019 21:14:53 +0000 (14:14 -0700)]
Asyncsocket in low latency send mode may write into freed memory
Blast service encounters access violation exception during scale tests
in AsyncTCPSocketSend() at bora\lib\asyncsocket\asyncsocket.c.
Root cause is asock refcount is not incremented before the inline
invocation of AsyncTCPSocketSendCallback() in the low latency send
mode and asock is accessed right after this invocation to decrement
inLowLatencySendCb counter. AsyncTCPSocketSendCallback() on error
would invoke error handler which in turn could close the asock
leading to freeing of asock.
Issue wouldn't happen if AsyncWebSocket impl guarded all of its
transport->send(transport) calls with AsyncSocketAddRef(transport)
and AsyncSocketRelease(transport) but isn't the case currently.
Fix is to add and release asock reference around the inline
invocation of AsyncTCPSocketSendCallback().
Oliver Kurth [Wed, 10 Apr 2019 21:14:52 +0000 (14:14 -0700)]
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.
Oliver Kurth [Wed, 10 Apr 2019 21:14:49 +0000 (14:14 -0700)]
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 proceedeing with the file transfer.
Oliver Kurth [Thu, 28 Mar 2019 19:43:00 +0000 (12:43 -0700)]
Remove the /etc/security directory from the guest vm-support bundle.
This directory contains sensitive guest side data that we should not
expose to the host side.
Although running the vm-support requires the root privilege in the guest,
the guest admin might not be aware of the ramification of running the script.
Therefore, better be cautious.
No file from the /etc/security has been needed in the past. If any file is
needed in the future, that need will be evaluated case-by-case at that time.
Oliver Kurth [Thu, 28 Mar 2019 19:42:59 +0000 (12:42 -0700)]
Fix a memory leak in vmbackup.
Note: vm_free() is called here because GuestApp_GetConfPath() is calling
Util_SafeStrdup() to allocate the memory. Both GuestApp_GetConfPath and
vm_free are implemented inside libvmtools.so.
Oliver Kurth [Thu, 28 Mar 2019 19:42:59 +0000 (12:42 -0700)]
Fix memory leak in GetFormattedCommandLine() function (linuxDeployment.c)
1. There are malloc() calls happening in a loop; this function returns
NULL when one of malloc fails. If a malloc call fails in the loop,
all memory allocated in previous iterations should be freed before
the return NULL.
2. Clear allocated resources before return NULL in this file.
3. Add NULL check following malloc calls in this file.
4. Encapsulate %s in () only if %s is strerror(errno), otherwise encapsulate
%s in single quotes.
5. End with \n in sLog.