From: Kamalesh Babulal Date: Thu, 2 Jun 2022 16:01:18 +0000 (-0600) Subject: wrapper: null terminated string in cgroup_add_controller() X-Git-Tag: v2.0.3~46 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=12d327eefca5aa0d4c63a6d870287bc2d28e34a4;p=thirdparty%2Flibcgroup.git wrapper: null terminated string in cgroup_add_controller() Fix non-terminated string warning, reported by Coverity tool: CID 258271 (#1 of 1): String not null terminated (STRING_NULL). string_null: Passing unterminated string cgc->name to strcmp, which expects a null-terminated string. This issue was reported following the path src/abstraction-common.c: - cgroup_convert_cgroup() - cgroup_add_controller() Signed-off-by: Kamalesh Babulal Signed-off-by: Tom Hromatka --- diff --git a/src/wrapper.c b/src/wrapper.c index 98ebcc26..5ffdb0b4 100644 --- a/src/wrapper.c +++ b/src/wrapper.c @@ -83,6 +83,8 @@ struct cgroup_controller *cgroup_add_controller(struct cgroup *cgroup, return NULL; strncpy(controller->name, name, sizeof(controller->name) - 1); + controller->name[sizeof(controller->name) - 1] = '\0'; + controller->cgroup = cgroup; controller->index = 0;