2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-30 22:05:36 +00:00

proc_parse: Make sure the fields in parsing stream do match

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
This commit is contained in:
Cyrill Gorcunov
2012-01-15 02:20:57 +04:00
parent 976c092c3f
commit 05c142c0f5

View File

@@ -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)