From 716a104cf5788ee521ac83f41b286492a0cb802f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nikola=20Forr=C3=B3?= Date: Mon, 6 Jan 2020 09:09:30 -0700 Subject: [PATCH] parse.y: Fix type declaration for group_name MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The group_name grammar rule was incorrectly defined as returning a type which is an int. It actually returns a type 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 Signed-off-by: Nikola Forró Acked-by: Michal Koutný --- src/parse.y | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/parse.y b/src/parse.y index 98f7699d..e67ad54e 100644 --- a/src/parse.y +++ b/src/parse.y @@ -45,9 +45,9 @@ int yywrap(void) int val; struct cgroup_dictionary *values; } -%type ID DEFAULT +%type ID DEFAULT group_name %type mountvalue_conf mount task_namevalue_conf admin_namevalue_conf -%type admin_conf task_conf task_or_admin group_conf group start group_name +%type admin_conf task_conf task_or_admin group_conf group start %type namespace namespace_conf default default_conf %type namevalue_conf %type template template_conf -- 2.47.2