The group_name grammar rule was incorrectly defined as
returning a type<val> which is an int.  It actually returns
a type<name> which is a char *.

Having group_name declared as val (int) and assigning a char * value
to it can lead to crashes on platforms where pointer size exceeds
size of int.

On newer versions of Bison, this bug led to the following
warnings during compilation:

parse.y: In function ‘yyparse’:
parse.y:106:56: warning: passing argument 1 of
    ‘cgroup_config_insert_cgroup’ makes pointer from integer
    without a cast [-Wint-conversion]
    106 |    $$ = cgroup_config_insert_cgroup($2);
        |                                                        ^
        |                                                        |
        |                                                        int

In file included from parse.y:21:
./libcgroup-internal.h:231:39: note: expected ‘char *’ but argument is
    of type ‘int’
    231 | int cgroup_config_insert_cgroup(char *cg_name);
        |                                 ~~~~~~^~~~~~~

parse.y:125:15: warning: assignment to ‘int’ from ‘char *’ makes integer
    from pointer without a cast [-Wint-conversion]
    125 |   $$ = $1;
        |               ^

parse.y:129:15: warning: assignment to ‘int’ from ‘char *’ makes integer
    from pointer without a cast [-Wint-conversion]
    129 |   $$ = $1;
        |               ^

parse.y: In function ‘yyparse’:
parse.y:106:56: warning: passing argument 1 of
    ‘cgroup_config_insert_cgroup’ makes pointer from integer without a cast
    [-Wint-conversion]
    106 |    $$ = cgroup_config_insert_cgroup($2);
        |                                                        ^
        |                                                        |
        |                                                        int

In file included from parse.y:21:
./libcgroup-internal.h:231:39: note: expected ‘char *’ but argument is
    of type ‘int’
    231 | int cgroup_config_insert_cgroup(char *cg_name);
        |                                 ~~~~~~^~~~~~~
parse.y:125:15: warning: assignment to ‘int’ from ‘char *’ makes integer
    from pointer without a cast [-Wint-conversion]
    125 |   $$ = $1;
        |               ^

parse.y:129:15: warning: assignment to ‘int’ from ‘char *’ makes integer
    from pointer without a cast [-Wint-conversion]
    129 |   $$ = $1;
        |               ^

Signed-off-by: Tom Hromatka <tom.hroma...@oracle.com>
Signed-off-by: Nikola Forró <nfo...@redhat.com>
Acked-by: Michal Koutný <mkou...@suse.com>
---
 src/parse.y | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/parse.y b/src/parse.y
index 98f7699d2c00..e67ad54e6f34 100644
--- a/src/parse.y
+++ b/src/parse.y
@@ -45,9 +45,9 @@ int yywrap(void)
        int val;
        struct cgroup_dictionary *values;
 }
-%type <name> ID DEFAULT
+%type <name> ID DEFAULT group_name
 %type <val> mountvalue_conf mount task_namevalue_conf admin_namevalue_conf
-%type <val> admin_conf task_conf task_or_admin group_conf group start 
group_name
+%type <val> admin_conf task_conf task_or_admin group_conf group start
 %type <val> namespace namespace_conf default default_conf
 %type <values> namevalue_conf
 %type <val> template template_conf
-- 
1.8.3.1



_______________________________________________
Libcg-devel mailing list
Libcg-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libcg-devel

Reply via email to