changeset 100250:41eda8c1e9ca

(procfs_system_process_attributes): If `nread' has a negative value, assign zero to it.
author Eli Zaretskii <eliz@gnu.org>
date Fri, 05 Dec 2008 16:44:56 +0000
parents 8cc99245d731
children 71adc10e543f
files src/process.c
diffstat 1 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/process.c	Fri Dec 05 16:30:01 2008 +0000
+++ b/src/process.c	Fri Dec 05 16:44:56 2008 +0000
@@ -7434,6 +7434,14 @@
 	  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 @@
 	    }
 	  cmdline_size = nread;
 	}
-      else
+      if (!cmdline_size)
 	{
 	  if (!cmd)
 	    cmd = "???";