Commit 05c142c0 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov

proc_parse: Make sure the fields in parsing stream do match

Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
parent 976c092c
......@@ -178,6 +178,7 @@ int parse_pid_stat(pid_t pid, int pid_dir, struct proc_pid_stat *s)
{
FILE *f;
char *tok;
int n;
f = fopen_proc(pid_dir, "stat");
if (f == NULL) {
......@@ -186,7 +187,7 @@ int parse_pid_stat(pid_t pid, int pid_dir, struct proc_pid_stat *s)
}
memset(s, 0, sizeof(*s));
fscanf(f,
n = fscanf(f,
"%d " TASK_COMM_LEN_FMT " %c %d %d %d %d %d %u %lu %lu %lu %lu "
"%lu %lu %ld %ld %ld %ld %d %d %llu %lu %ld %lu %lu %lu %lu "
"%lu %lu %lu %lu %lu %lu %lu %lu %lu %d %d %u %u %llu %lu %ld "
......@@ -239,6 +240,11 @@ int parse_pid_stat(pid_t pid, int pid_dir, struct proc_pid_stat *s)
&s->end_data,
&s->start_brk);
if (n != 47) {
pr_perror("Parsing %d's stat failed (#fields do not match)", pid);
return -1;
}
s->comm[TASK_COMM_LEN-1] = '\0';
tok = strchr(s->comm, ')');
if (tok)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment