mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-30 21:43:13 +00:00
cgroup: don't overwrite the offset value in a loop (v2)
prepare_cgroup_dirs() gets a path and an offset. Then we add substrings to the source string and handle them. v2: fix one more place in prepare_cgroup_dir_properties() Cc: Tycho Andersen <tycho.andersen@canonical.com> Signed-off-by: Andrew Vagin <avagin@openvz.org> Acked-by: Tycho Andersen <tycho.andersen@canonical.com> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
parent
14c65e91fa
commit
bbdff34803
1 changed files with 6 additions and 4 deletions
10
cgroup.c
10
cgroup.c
|
|
@ -974,8 +974,9 @@ static int prepare_cgroup_dir_properties(char *path, int off, CgroupDirEntry **e
|
|||
|
||||
for (i = 0; i < n_ents; i++) {
|
||||
CgroupDirEntry *e = ents[i];
|
||||
size_t off2 = off;
|
||||
|
||||
off += sprintf(path + off, "/%s", e->dir_name);
|
||||
off2 += sprintf(path + off, "/%s", e->dir_name);
|
||||
/*
|
||||
* Check to see if we made e->properties NULL during restore
|
||||
* because directory already existed and as such we don't want to
|
||||
|
|
@ -988,7 +989,7 @@ static int prepare_cgroup_dir_properties(char *path, int off, CgroupDirEntry **e
|
|||
}
|
||||
}
|
||||
|
||||
if (prepare_cgroup_dir_properties(path, off, e->children, e->n_children) < 0)
|
||||
if (prepare_cgroup_dir_properties(path, off2, e->children, e->n_children) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -1022,9 +1023,10 @@ static int prepare_cgroup_dirs(char *paux, size_t off, CgroupDirEntry **ents, si
|
|||
CgroupDirEntry *e;
|
||||
|
||||
for (i = 0; i < n_ents; i++) {
|
||||
size_t off2 = off;
|
||||
e = ents[i];
|
||||
|
||||
off += sprintf(paux + off, "/%s", e->dir_name);
|
||||
off2 += sprintf(paux + off, "/%s", e->dir_name);
|
||||
|
||||
/*
|
||||
* Checking to see if file already exists. If not, create it. If
|
||||
|
|
@ -1046,7 +1048,7 @@ static int prepare_cgroup_dirs(char *paux, size_t off, CgroupDirEntry **ents, si
|
|||
pr_info("Determined dir %s already existed\n", paux);
|
||||
}
|
||||
|
||||
if (prepare_cgroup_dirs(paux, off, e->children, e->n_children) < 0)
|
||||
if (prepare_cgroup_dirs(paux, off2, e->children, e->n_children) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue