Skip to contentSkip to conversation

libsepol/cil: Do not check flavor when checking for duplicate parameters

PATCH Applied James Carter 2 participants 3 messages Mar 4, 2020 – Mar 11, 2020 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libsepol/cil: Do not check flavor when checking for duplicate parameters

A parameter of a macro was only considered to be a duplicate if it matched both the name and flavor of another parameter. While it is true that CIL is able to differentiate between those two parameters, there is no reason to use the same name for two macro parameters and it is better to return an error for what is probably an error.

Remove the check of the flavors when checking for duplicate parameters.

---
 libsepol/cil/src/cil_build_ast.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
libsepol/cil/src/cil_build_ast.c +3 -5
index 307b1ee3..fcecdc4f 100644
@@ -5304,11 +5304,9 @@ int cil_gen_macro(struct cil_db *db, struct cil_tree_node *parse_current, struct
 		struct cil_list_item *curr_param;
 		cil_list_for_each(curr_param, macro->params) {
 			if (param->str == ((struct cil_param*)curr_param->data)->str) {
-				if (param->flavor == ((struct cil_param*)curr_param->data)->flavor) {
-					cil_log(CIL_ERR, "Duplicate parameter\n");
-					cil_destroy_param(param);
-					goto exit;
-				}
+				cil_log(CIL_ERR, "Duplicate parameter\n");
+				cil_destroy_param(param);
+				goto exit;
 			}
 		}
 
Signature · 1 line
2.17.1
Acked-by on v1 1/1
#1 lore raw
Quoted 33 lines · James Carter

A parameter of a macro was only considered to be a duplicate if it matched both the name and flavor of another parameter. While it is true that CIL is able to differentiate between those two parameters, there is no reason to use the same name for two macro parameters and it is better to return an error for what is probably an error.

Remove the check of the flavors when checking for duplicate parameters.

---
 libsepol/cil/src/cil_build_ast.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
libsepol/cil/src/cil_build_ast.c +3 -6
index 307b1ee3..fcecdc4f 100644
@@ -5304,11 +5304,9 @@ int cil_gen_macro(struct cil_db *db, struct cil_tree_node *parse_current, struct
                struct cil_list_item *curr_param;
                cil_list_for_each(curr_param, macro->params) {
                        if (param->str == ((struct cil_param*)curr_param->data)->str) {
-                               if (param->flavor == ((struct cil_param*)curr_param->data)->flavor) {
-                                       cil_log(CIL_ERR, "Duplicate parameter\n");
-                                       cil_destroy_param(param);
-                                       goto exit;
-                               }
+                               cil_log(CIL_ERR, "Duplicate parameter\n");
+                               cil_destroy_param(param);
+                               goto exit;
                        }
                }
 
--
Quoted 2 lines

2.17.1

--
Ondrej Mosnacek <omosnace at redhat dot com>
Software Engineer, Security Technologies
Red Hat, Inc.

#2 lore raw
Quoted 33 lines · Ondrej Mosnacek
Quoted 32 lines · James Carter

A parameter of a macro was only considered to be a duplicate if it matched both the name and flavor of another parameter. While it is true that CIL is able to differentiate between those two parameters, there is no reason to use the same name for two macro parameters and it is better to return an error for what is probably an error.

Remove the check of the flavors when checking for duplicate parameters.

---
 libsepol/cil/src/cil_build_ast.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
libsepol/cil/src/cil_build_ast.c +3 -5
index 307b1ee3..fcecdc4f 100644
@@ -5304,11 +5304,9 @@ int cil_gen_macro(struct cil_db *db, struct cil_tree_node *parse_current, struct
                struct cil_list_item *curr_param;
                cil_list_for_each(curr_param, macro->params) {
                        if (param->str == ((struct cil_param*)curr_param->data)->str) {
-                               if (param->flavor == ((struct cil_param*)curr_param->data)->flavor) {
-                                       cil_log(CIL_ERR, "Duplicate parameter\n");
-                                       cil_destroy_param(param);
-                                       goto exit;
-                               }
+                               cil_log(CIL_ERR, "Duplicate parameter\n");
+                               cil_destroy_param(param);
+                               goto exit;
                        }
                }
 
Quoted 5 lines
Quoted 3 lines

--
2.17.1

Applied, thanks.

Signature · 3 lines
Ondrej Mosnacek <omosnace at redhat dot com>
Software Engineer, Security Technologies
Red Hat, Inc.