From: Werner Fink Date: Tue, 13 Mar 2012 12:39:52 +0000 (+0100) Subject: Really add ASCII null at command string in add_proc() of pstree.c X-Git-Tag: v22.17~9^2~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=de186957b94e4298075dfaff4b134a1c7a72ac07;p=psmisc Really add ASCII null at command string in add_proc() of pstree.c Signed-off-by: Werner Fink --- diff --git a/ChangeLog b/ChangeLog index 45f6c04..b42a4d7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,5 @@ + * Really add ASCII null at command string in add_proc() of pstree.c + Changes in 22.16 ================ * Use strncpy for COMM_LEN and make it 18 characters to cover brackets diff --git a/src/pstree.c b/src/pstree.c index 80cfcec..a6c8f6e 100644 --- a/src/pstree.c +++ b/src/pstree.c @@ -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+1]='\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,7 +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->comm[COMM_LEN+1] = '\0'; this->uid = uid; } if (args)