On 05/09/2013 11:13 AM, Ivana Hutarova Varekova wrote:
> 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 <varek...@redhat.com>

Acked-By: Jan Safranek <jsafr...@redhat.com>

> ---
> 
>  src/config.c |   11 +++++++----
>  1 files changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/src/config.c b/src/config.c
> index f339a73..f3ac4dd 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;
>  
> 
> 
> ------------------------------------------------------------------------------
> Learn Graph Databases - Download FREE O'Reilly Book
> "Graph Databases" is the definitive new guide to graph databases and 
> their applications. This 200-page book is written by three acclaimed 
> leaders in the field. The early access version is available now. 
> Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
> _______________________________________________
> Libcg-devel mailing list
> Libcg-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/libcg-devel
> 


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and 
their applications. This 200-page book is written by three acclaimed 
leaders in the field. The early access version is available now. 
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
_______________________________________________
Libcg-devel mailing list
Libcg-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libcg-devel

Reply via email to