]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
wrapper.c: fix string non-termination warning
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Wed, 6 Jul 2022 20:13:29 +0000 (14:13 -0600)
committerTom Hromatka <tom.hromatka@oracle.com>
Wed, 6 Jul 2022 20:13:32 +0000 (14:13 -0600)
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 <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit 0fd476b6a6f309ccd3b0c473c844a27e7620cddd)

src/wrapper.c

index 5ffdb0b4f54b23ecdb5f9d9befd569b38d2542ef..5d9431f3600a2865c19eb33dcf0803cecb5df700 100644 (file)
@@ -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