]> git.eshelyaron.com Git - emacs.git/commitdiff
(procfs_system_process_attributes): If `nread' has a negative value, assign
authorEli Zaretskii <eliz@gnu.org>
Fri, 5 Dec 2008 16:49:20 +0000 (16:49 +0000)
committerEli Zaretskii <eliz@gnu.org>
Fri, 5 Dec 2008 16:49:20 +0000 (16:49 +0000)
zero to it.

src/ChangeLog
src/process.c

index ce8ac092da942ab0cc0078e555f2999869b5b7ab..59ae73d0213ed61d20aadd5dc8bfc3afbc7b74f7 100644 (file)
@@ -1,3 +1,8 @@
+2008-12-05  Eli Zaretskii  <eliz@gnu.org>
+
+       * process.c (procfs_system_process_attributes): If `nread' has a
+       negative value, assign zero to it.
+
 2008-12-05  Chong Yidong  <cyd@stupidchicken.com>
 
        * eval.c (Vdebug_on_error): Doc fix.
index b5d2f3d4c9f36dae7caf66bedd9c24c34661dc5f..5084bc8d159f1684b3af834bb86f67d15a81cbd4 100644 (file)
@@ -7434,6 +7434,14 @@ procfs_system_process_attributes (pid)
          cmdline[0] = '\0';
          if ((nread = read (fd, cmdline, cmdline_size)) >= 0)
            cmdline[nread++] = '\0';
+         else
+           {
+             /* Assigning zero to `nread' makes us skip the following
+                two loops, assign zero to cmdline_size, and enter the
+                following `if' clause that handles unknown command
+                lines.  */
+             nread = 0;
+           }
          /* We don't want trailing null characters.  */
          for (p = cmdline + nread - 1; p > cmdline && !*p; p--)
            nread--;
@@ -7451,7 +7459,7 @@ procfs_system_process_attributes (pid)
            }
          cmdline_size = nread;
        }
-      else
+      if (!cmdline_size)
        {
          if (!cmd)
            cmd = "???";