From b5ec91a5c0c59a6c4f296af4716b4409e5988a53 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Fri, 5 Dec 2008 16:49:20 +0000 Subject: [PATCH] (procfs_system_process_attributes): If `nread' has a negative value, assign zero to it. --- src/ChangeLog | 5 +++++ src/process.c | 10 +++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/ChangeLog b/src/ChangeLog index ce8ac092da9..59ae73d0213 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2008-12-05 Eli Zaretskii + + * process.c (procfs_system_process_attributes): If `nread' has a + negative value, assign zero to it. + 2008-12-05 Chong Yidong * eval.c (Vdebug_on_error): Doc fix. diff --git a/src/process.c b/src/process.c index b5d2f3d4c9f..5084bc8d159 100644 --- a/src/process.c +++ b/src/process.c @@ -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 = "???"; -- 2.39.2