]> 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:12:28 +0000 (14:12 -0600)
committerTom Hromatka <tom.hromatka@oracle.com>
Wed, 6 Jul 2022 20:12:32 +0000 (14:12 -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>
src/wrapper.c

index 933075dfcfa4307a4b8f7a73adc711deb3e5ca86..c3d766d223a9cb4eee94df65f76fa5c37a6fbc1b 100644 (file)
@@ -687,6 +687,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, ".");
 
                /*