From a8f3daf54136de7e02fc2cf153ad55051ce95ab4 Mon Sep 17 00:00:00 2001 From: Balbir Singh Date: Sat, 20 Sep 2008 00:56:09 +0000 Subject: [PATCH] Once we build the path, we don't have all the room in path anymore. Instead of using sizeof(path), we should use FILENAME_MAX - strlen(path) - 1. Signed-off-by: Balbir Singh git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@186 4f4bb910-9a46-0410-90c8-c897d4f1cd53 --- api.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/api.c b/api.c index fef34c10..fc7e18ab 100644 --- a/api.c +++ b/api.c @@ -293,7 +293,7 @@ static char *cg_build_path_locked(char *name, char *path, char *type) return NULL; } -static char *cg_build_path(char *name, char *path, char *type) +char *cg_build_path(char *name, char *path, char *type) { pthread_rwlock_rdlock(&cg_mount_table_lock); path = cg_build_path_locked(name, path, type); @@ -1041,12 +1041,14 @@ struct cgroup *cgroup_get_cgroup(struct cgroup *cgroup) */ struct cgroup_controller *cgc; struct stat stat_buffer; + int path_len; if (!cg_build_path_locked(NULL, path, cg_mount_table[i].name)) continue; - strncat(path, cgroup->name, sizeof(path)); + path_len = strlen(path); + strncat(path, cgroup->name, FILENAME_MAX - path_len - 1); if (access(path, F_OK)) continue; -- 2.47.2