Skip to content

Commit fada3bd

Browse files
cgroup: initialize controllers buffer to 0s (#106)
Initialize controllers buffer to 0s in case there are no cgroups controllers and reading "cgroup.controllers" results in 0 bytes. Without this, the controllers buffer contents is undefined and then later on we attempt to strtok on the undefined buffer to split it on spaces which can yield undefined results.
1 parent 3f97bb7 commit fada3bd

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Diff for: cgroup.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ void cgroup_start_cleaner(int parentfd, const char *name)
282282

283283
void cgroup_enable_controllers(int cgroupfd)
284284
{
285-
char controllers[BUFSIZ];
285+
char controllers[BUFSIZ] = {0};
286286
int cfd = openat(cgroupfd, "cgroup.controllers", O_RDONLY, 0);
287287
if (cfd == -1) {
288288
err(1, "cgroup_enable_controllers: open cgroup.controllers");

0 commit comments

Comments
 (0)