Skip to content

Commit

Permalink
cgroup: initialize controllers buffer to 0s (#106)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
travisshivers authored Dec 31, 2024
1 parent 3f97bb7 commit fada3bd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion cgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ void cgroup_start_cleaner(int parentfd, const char *name)

void cgroup_enable_controllers(int cgroupfd)
{
char controllers[BUFSIZ];
char controllers[BUFSIZ] = {0};
int cfd = openat(cgroupfd, "cgroup.controllers", O_RDONLY, 0);
if (cfd == -1) {
err(1, "cgroup_enable_controllers: open cgroup.controllers");
Expand Down

0 comments on commit fada3bd

Please sign in to comment.