]> granicus.if.org Git - procps-ng/commitdiff
stop chopping cmd off short
authoralbert <>
Sat, 7 Dec 2002 08:34:03 +0000 (08:34 +0000)
committeralbert <>
Sat, 7 Dec 2002 08:34:03 +0000 (08:34 +0000)
proc/readproc.c

index 6ed06620b8deb7c3afd522f6c2d6350d13bce137..83ef66aab620b8c8c5e3d3a15f4d38dc338fc692 100644 (file)
@@ -182,8 +182,7 @@ static void stat2proc(const char* S, proc_t *restrict P) {
     S = tmp + 2;
     tmp = strrchr(S, ')');      // split into "PID (cmd" and "<rest>"
     num = tmp - S;
-    if(unlikely(num > sizeof P->cmd)) num = sizeof P->cmd; // 1 too big
-    num--;                       // ditch the ')' character
+    if(unlikely(num >= sizeof P->cmd)) num = sizeof P->cmd - 1;
     memcpy(P->cmd, S, num);
     P->cmd[num] = '\0';
     S = tmp + 2;                 // skip ") "