From 049774b40273e8427d0658d505a63d8814491db5 Mon Sep 17 00:00:00 2001 From: Ivana Hutarova Varekova Date: Thu, 9 May 2013 14:04:00 +0200 Subject: [PATCH] templates have to be coppied in proper way to template_table structure cgroup_reload_cached_templates and cgroup_init_templates_cache functions fill structure template_table in old version the data are coppied (memcpy function) from config_template_table. This causes problem if both template_table and config_template_table are reloaded or if config_template_table is updated. Patch fix this problem and copy data properly (cgroup_copy_cgroup function) The reproducer of this bug is described in http://sourceforge.net/mailarchive/forum.php?thread_name=khtfkj%24c8l%241%40ger.gmane.org&forum_name=libcg-devel Signed-off-by: Ivana Hutarova Varekova Acked-By: Jan Safranek --- src/config.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/config.c b/src/config.c index f339a733..f3ac4dd8 100644 --- a/src/config.c +++ b/src/config.c @@ -1472,8 +1472,9 @@ int cgroup_reload_cached_templates(char *pathname) return ret; } - memcpy(template_table, config_template_table, - template_table_index * sizeof(struct cgroup)); + for (i = 0; i < template_table_index; i++) { + cgroup_copy_cgroup(&config_template_table[i], &template_table[i]); + } return ret; } @@ -1485,6 +1486,7 @@ int cgroup_reload_cached_templates(char *pathname) int cgroup_init_templates_cache(char *pathname) { int ret = 0; + int i; if (config_template_table_index != 0) { /* config structures have to be clean */ @@ -1508,8 +1510,9 @@ int cgroup_init_templates_cache(char *pathname) return ret; } - memcpy(template_table, config_template_table, - template_table_index * sizeof(struct cgroup)); + for (i = 0; i < template_table_index; i++) { + cgroup_copy_cgroup(&config_template_table[i], &template_table[i]); + } return ret; -- 2.47.2