]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
templates have to be coppied in proper way to template_table structure
authorIvana Hutarova Varekova <varekova@redhat.com>
Thu, 9 May 2013 12:04:00 +0000 (14:04 +0200)
committerIvana Hutarova Varekova <varekova@redhat.com>
Thu, 9 May 2013 12:04:00 +0000 (14:04 +0200)
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 <varekova@redhat.com>
Acked-By: Jan Safranek <jsafrane@redhat.com>
src/config.c

index f339a7331af05e1e6375582db94fd3ec34eb0355..f3ac4dd85c4a332f3e5f77bcc86ab4679cdad2b4 100644 (file)
@@ -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;