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.hromatka@oracle.com>
Signed-off-by: Nikola Forró <nforro@redhat.com>
Acked-by: Michal Koutný <mkoutny@suse.com>
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