From fada3bd15aa46d597468353875f6ee82da2ce1b5 Mon Sep 17 00:00:00 2001 From: travisshivers Date: Mon, 30 Dec 2024 18:07:26 -0600 Subject: [PATCH] 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. --- cgroup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cgroup.c b/cgroup.c index 72a03ab..651a6b0 100644 --- a/cgroup.c +++ b/cgroup.c @@ -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");