From: Oliver Kurth Date: Wed, 3 Jul 2019 21:28:56 +0000 (-0700) Subject: Fix process command name for special linux processes. X-Git-Tag: stable-11.0.0~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=47c8f75e4516552615c070c6920633f7e8e572a0;p=thirdparty%2Fopen-vm-tools.git Fix process command name for special linux processes. While listing down the processes in a linux guest, the existing procMgr library reads /proc//cmdline file and parses the content. While reading this, an assumption is made that there is a null terminating character at the end of the file content. This holds true for most of the processes. But for few special processes, the cmdline file doesn't have the terminating null character. Proper content from cmdline file: /usr/lib/systemd/systemd\0--switched-root\0--system\0--deserialize\021\0 /usr/sbin/vmtoolsd\0 sshd: root@pts/2\0\0\0 Example cmdline file where NUL terminator is missing: avahi-daemon: running [linux.local] avahi-daemon: chroot helper --- diff --git a/open-vm-tools/lib/procMgr/procMgrPosix.c b/open-vm-tools/lib/procMgr/procMgrPosix.c index e38a6dbf6..8acde5c98 100644 --- a/open-vm-tools/lib/procMgr/procMgrPosix.c +++ b/open-vm-tools/lib/procMgr/procMgrPosix.c @@ -403,7 +403,8 @@ ProcMgr_ListProcesses(void) if (numRead > 0) { for (replaceLoop = 0 ; replaceLoop < numRead ; replaceLoop++) { - if ('\0' == cmdLineTemp[replaceLoop]) { + if ('\0' == cmdLineTemp[replaceLoop] || + replaceLoop == numRead - 1) { if (cmdNameLookup) { /* * Store the command name.