From: Kamalesh Babulal Date: Tue, 7 Feb 2023 23:22:50 +0000 (-0700) Subject: wrapper: fix segfault in cgroup_new_cgroup() X-Git-Tag: v3.1.0~221 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a8973c694a83229ef74e96e44a740dceabff1db3;p=thirdparty%2Flibcgroup.git wrapper: fix segfault in cgroup_new_cgroup() 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 Signed-off-by: Tom Hromatka --- diff --git a/src/wrapper.c b/src/wrapper.c index a1a1efbf..0e724116 100644 --- a/src/wrapper.c +++ b/src/wrapper.c @@ -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;