[CRIU] [PATCH] proc: Make sure eol remains on task name

Cyrill Gorcunov gorcunov at openvz.org
Thu Apr 26 13:43:08 EDT 2012


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 at 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



More information about the CRIU mailing list