]> granicus.if.org Git - psmisc/commitdiff
Null terminate some strings
authorCraig Small <csmall@users.sourceforge.net>
Sun, 26 Feb 2012 04:18:42 +0000 (15:18 +1100)
committerCraig Small <csmall@users.sourceforge.net>
Sun, 26 Feb 2012 04:18:42 +0000 (15:18 +1100)
ChangeLog
src/killall.c
src/pstree.c

index cf95c4b1804eb097931c45674236add270dce21c..45f6c04a1468d756ff0b875fde630c42b83c1646 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,8 @@ Changes in 22.16
 ================
        * Use strncpy for COMM_LEN and make it 18 characters to cover brackets
          in name.
+       * don't change COMM_LEN, it breaks matching long commands
+         Debian #661145
        * Enable some harden AM_CFLAGS by default, use configure option
          --disable-harden-flags to not use it.
 
index f108c778c55ea7a89e27e7949a7a9a7ea2785912..da26237ecab634724fc78f90d8d62f95af8f5acb 100644 (file)
@@ -768,12 +768,14 @@ main (int argc, char **argv)
     case 'y':
       NOT_PIDOF_OPTION;
       strncpy(yt, optarg, 16);
+         yt[15] = '\0';
       if ( 0 >= (younger_than = parse_time_units(yt) ) )
            usage(_("Invalid time format"));
       break;
     case 'o':
       NOT_PIDOF_OPTION;
       strncpy(ot, optarg, 16);
+         ot[15] = '\0';
       if ( 0 >= (older_than = parse_time_units(ot) ) )
            usage(_("Invalid time format"));
       break;
index 183a96676f85eb1ddfb7a821eb5b55ec6a8c6dd2..80cfcec99d3afd52e82980b30172180c9ae24579 100644 (file)
@@ -265,7 +265,7 @@ static PROC *new_proc(const char *comm, pid_t pid, uid_t uid)
         exit(1);
     }
     strncpy(new->comm, comm, COMM_LEN+2);
-       new->comm[COMM_LEN+2]='\0'; /* make sure nul terminated*/
+       new->comm[COMM_LEN+1]='\0'; /* make sure nul terminated*/
     new->pid = pid;
     new->uid = uid;
     new->flags = 0;
@@ -354,6 +354,7 @@ add_proc(const char *comm, pid_t pid, pid_t ppid, uid_t uid,
 #endif                                /*WITH_SELINUX */
     else {
         strncpy(this->comm, comm, COMM_LEN+2);
+               this->comm[COMM_LEN+1];
         this->uid = uid;
     }
     if (args)