From: Kamalesh Babulal Date: Wed, 20 Jul 2022 17:10:03 +0000 (-0600) Subject: wrapper.c: null terminate string in cgroup_new_cgroup() X-Git-Tag: v3.0~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=239b3c4154e8129b62db0f1743f3e947e6932871;p=thirdparty%2Flibcgroup.git wrapper.c: null terminate string in cgroup_new_cgroup() Fix non-terminated string warning, reported by Coverity tool: CID 258290 (#1 of 1): String not null terminated (STRING_NULL)46. string_null: Passing unterminated string aux_cgroup->name to cgroup_create_cgroup, which expects a null-terminated string. The call patch leading to this warning: config.c::cgroup_config_create_template_group() - wrapper.c::cgroup_new_cgroup() fix it by null terminating the string. Signed-off-by: Kamalesh Babulal Signed-off-by: Tom Hromatka --- diff --git a/src/wrapper.c b/src/wrapper.c index 14272283..a1a1efbf 100644 --- a/src/wrapper.c +++ b/src/wrapper.c @@ -48,7 +48,8 @@ struct cgroup *cgroup_new_cgroup(const char *name) return NULL; init_cgroup(cgroup); - strncpy(cgroup->name, name, sizeof(cgroup->name) - 1); + strncpy(cgroup->name, name, FILENAME_MAX - 1); + cgroup->name[FILENAME_MAX - 1] = '\0'; return cgroup; }