]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Fix process command name for special linux processes.
authorOliver Kurth <okurth@vmware.com>
Wed, 3 Jul 2019 21:28:56 +0000 (14:28 -0700)
committerOliver Kurth <okurth@vmware.com>
Wed, 3 Jul 2019 21:28:56 +0000 (14:28 -0700)
While listing down the processes in a linux guest, the existing
procMgr library reads /proc/<PID>/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

open-vm-tools/lib/procMgr/procMgrPosix.c

index e38a6dbf60fbadce268928e4d6c0801d9cf6f249..8acde5c983b11933e2e32c7a850a77c871334164 100644 (file)
@@ -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.