From: Nikola Forró Date: Mon, 6 Jan 2020 16:09:30 +0000 (-0700) Subject: parse.y: Fix type declaration for group_name X-Git-Tag: v0.42~3^2~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=716a104cf5788ee521ac83f41b286492a0cb802f;p=thirdparty%2Flibcgroup.git parse.y: Fix type declaration for group_name 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ý --- 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