summaryrefslogtreecommitdiffstats
path: root/api.c
diff options
context:
space:
mode:
authorBalbir Singh <balbir@linux.vnet.ibm.com>2008-09-20 00:56:09 +0000
committerBalbir Singh <balbir@linux.vnet.ibm.com>2008-09-20 00:56:09 +0000
commita8f3daf54136de7e02fc2cf153ad55051ce95ab4 (patch)
tree3f409e4c88624bcb574d1662eca7c4508018efec /api.c
parent1450796033fc6c06694b4a4853f9c8c62e532564 (diff)
downloadlibcg-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.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/api.c b/api.c
index fef34c1..fc7e18a 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;