]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
wrapper: fix segfault in cgroup_new_cgroup()
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Tue, 7 Feb 2023 23:22:50 +0000 (16:22 -0700)
committerTom Hromatka <tom.hromatka@oracle.com>
Tue, 7 Feb 2023 23:22:57 +0000 (16:22 -0700)
Passing NULL in the place of the cgroup name as an argument to
cgroup_new_cgroup() API will segfault, fix by adding a check to validate
cgroup name.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
src/wrapper.c

index a1a1efbfd13bea8f537ac029c88f809947ebe493..0e7241161df8276680fdd2a79e85946421469284 100644 (file)
@@ -42,8 +42,12 @@ void init_cgroup_table(struct cgroup *cgroups, size_t count)
 
 struct cgroup *cgroup_new_cgroup(const char *name)
 {
-       struct cgroup *cgroup = calloc(1, sizeof(struct cgroup));
+       struct cgroup *cgroup;
 
+       if (!name)
+               return NULL;
+
+       cgroup = calloc(1, sizeof(struct cgroup));
        if (!cgroup)
                return NULL;