diff options
author | Balbir Singh <balbir@linux.vnet.ibm.com> | 2008-09-20 00:56:09 +0000 |
---|---|---|
committer | Balbir Singh <balbir@linux.vnet.ibm.com> | 2008-09-20 00:56:09 +0000 |
commit | a8f3daf54136de7e02fc2cf153ad55051ce95ab4 (patch) | |
tree | 3f409e4c88624bcb574d1662eca7c4508018efec /api.c | |
parent | 1450796033fc6c06694b4a4853f9c8c62e532564 (diff) | |
download | libcg-a8f3daf54136de7e02fc2cf153ad55051ce95ab4.tar.gz libcg-a8f3daf54136de7e02fc2cf153ad55051ce95ab4.tar.xz libcg-a8f3daf54136de7e02fc2cf153ad55051ce95ab4.zip |
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 <balbir@linux.vnet.ibm.com>
git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@186 4f4bb910-9a46-0410-90c8-c897d4f1cd53
Diffstat (limited to 'api.c')
-rw-r--r-- | api.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -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; |