From: Kamalesh Babulal Date: Mon, 28 Feb 2022 14:07:20 +0000 (+0530) Subject: api: fix strncpy() warning in cgroup_process_v2_mnt X-Git-Tag: v3.0~191 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=23068e8f107ed3de4bde36c15f5ff32c5ffcc835;p=thirdparty%2Flibcgroup.git api: fix strncpy() warning in cgroup_process_v2_mnt Fix a GCC warning about un-truncated strncpy() in cgroup_process_v2_mnt(): In function 'cgroup_process_v2_mnt', inlined from 'cgroup_init' at api.c:1387:10: api.c:1205:9: warning: 'strncpy' specified bound 4096 equals destination size [-Wstringop-truncation] 1205 | strncpy(cg_cgroup_v2_mount_path, ent->mnt_dir, FILENAME_MAX); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Kamalesh Babulal Signed-off-by: Tom Hromatka --- diff --git a/src/api.c b/src/api.c index 488cdd5f..69dce7fc 100644 --- a/src/api.c +++ b/src/api.c @@ -1202,7 +1202,8 @@ STATIC int cgroup_process_v2_mnt(struct mntent *ent, int *mnt_tbl_idx) * Save off this mount point. This may be used later to build * the cg_path. */ - strncpy(cg_cgroup_v2_mount_path, ent->mnt_dir, FILENAME_MAX); + strncpy(cg_cgroup_v2_mount_path, ent->mnt_dir, FILENAME_MAX-1); + cg_cgroup_v2_mount_path[FILENAME_MAX-1] = '\0'; /* determine what v2 controllers are available on this mount */ snprintf(cgroup_controllers_path, FILENAME_MAX, "%s/%s", ent->mnt_dir, diff --git a/tests b/tests index 3e786fc4..2aa90061 160000 --- a/tests +++ b/tests @@ -1 +1 @@ -Subproject commit 3e786fc4c024662cc38c8a39868354c55465f487 +Subproject commit 2aa90061eccb7dbd3d3ce7f6cdf2e087cf8a95a2