[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openvz-criu
Subject:    [CRIU] [PATCH 1/5] proc: Make sure eol remains on task name
From:       gorcunov () openvz ! org (Cyrill Gorcunov)
Date:       2012-04-27 18:13:38
Message-ID: 1335564808-10069-2-git-send-email-gorcunov () openvz ! org
[Download RAW message or body]

It is not a problem at moment since we define
TASK_COMM_LEN=16 exactly as defined in kernel,
but things might change in future so better
be on a safe side.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
---
 proc_parse.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/proc_parse.c b/proc_parse.c
index cd1e7d6..891c20c 100644
--- a/proc_parse.c
+++ b/proc_parse.c
@@ -220,7 +220,7 @@ int parse_pid_stat_small(pid_t pid, struct proc_pid_stat_small *s)
 	*tok = '\0';
 	*p = '\0';
 
-	strncpy(s->comm, tok + 1, sizeof(s->comm));
+	strncpy(s->comm, tok + 1, sizeof(s->comm) - 1);
 
 	n = sscanf(p + 1, " %c %d %d %d", &s->state, &s->ppid, &s->pgid, &s->sid);
 	if (n < 4)
@@ -269,7 +269,7 @@ int parse_pid_stat(pid_t pid, struct proc_pid_stat *s)
 	*tok = '\0';
 	*p = '\0';
 
-	strncpy(s->comm, tok + 1, sizeof(s->comm));
+	strncpy(s->comm, tok + 1, sizeof(s->comm) - 1);
 
 	n = sscanf(p + 1,
 	       " %c %d %d %d %d %d %u %lu %lu %lu %lu "
-- 
1.7.7.6

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic