From e60b87549089e35ba29a6cc1e209a0a019583878 Mon Sep 17 00:00:00 2001 From: Kamalesh Babulal Date: Wed, 6 Jul 2022 14:13:29 -0600 Subject: [PATCH] wrapper.c: fix string non-termination warning Fix non-terminated string warning, reported by Coverity tool: CID 258266 (#1 of 1): String not null-terminated (STRING_NULL). string_null: Passing unterminated string con to strtok, which expects a null-terminated string. Fix the warning in create_cgroup_from_name_value_pairs(), by adding '\0'. Signed-off-by: Kamalesh Babulal Signed-off-by: Tom Hromatka (cherry picked from commit 0fd476b6a6f309ccd3b0c473c844a27e7620cddd) --- src/wrapper.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/wrapper.c b/src/wrapper.c index 5ffdb0b4..5d9431f3 100644 --- a/src/wrapper.c +++ b/src/wrapper.c @@ -624,6 +624,8 @@ struct cgroup *create_cgroup_from_name_value_pairs(const char *name, } strncpy(con, name_value[i].name, FILENAME_MAX - 1); + con[FILENAME_MAX - 1] = '\0'; + strtok(con, "."); /* find out whether we have to add the controller or -- 2.47.2