mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-31 14:25:49 +00:00
cg: Minus one string copy in collect_cgroups
Signed-off-by: Pavel Emelyanov <xemul@parallels.com> Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
This commit is contained in:
9
cgroup.c
9
cgroup.c
@@ -14,6 +14,7 @@
|
|||||||
#include "proc_parse.h"
|
#include "proc_parse.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "fdset.h"
|
#include "fdset.h"
|
||||||
|
#include "string.h"
|
||||||
#include "protobuf.h"
|
#include "protobuf.h"
|
||||||
#include "protobuf/core.pb-c.h"
|
#include "protobuf/core.pb-c.h"
|
||||||
#include "protobuf/cgroup.pb-c.h"
|
#include "protobuf/cgroup.pb-c.h"
|
||||||
@@ -338,7 +339,7 @@ static int collect_cgroups(struct list_head *ctls)
|
|||||||
|
|
||||||
list_for_each_entry(cc, ctls, l) {
|
list_for_each_entry(cc, ctls, l) {
|
||||||
char path[PATH_MAX];
|
char path[PATH_MAX];
|
||||||
char *name, mount_point[PATH_MAX], prefix[] = ".criu.cgmounts.XXXXXX";
|
char *name, prefix[] = ".criu.cgmounts.XXXXXX";
|
||||||
bool temp_mount = false;
|
bool temp_mount = false;
|
||||||
struct cg_controller *cg;
|
struct cg_controller *cg;
|
||||||
|
|
||||||
@@ -347,7 +348,7 @@ static int collect_cgroups(struct list_head *ctls)
|
|||||||
else
|
else
|
||||||
name = cc->name;
|
name = cc->name;
|
||||||
|
|
||||||
if (get_cgroup_mount_point(name, mount_point) < 0) {
|
if (get_cgroup_mount_point(name, path) < 0) {
|
||||||
/* Someone is trying to dump a process that is in
|
/* Someone is trying to dump a process that is in
|
||||||
* a controller that isn't mounted, so we mount it for
|
* a controller that isn't mounted, so we mount it for
|
||||||
* them.
|
* them.
|
||||||
@@ -373,10 +374,10 @@ static int collect_cgroups(struct list_head *ctls)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(mount_point, prefix);
|
strcpy(path, prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(path, PATH_MAX, "%s%s", mount_point, cc->path);
|
strlcat(path, cc->path, PATH_MAX);
|
||||||
|
|
||||||
current_controller = NULL;
|
current_controller = NULL;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user