Blame SOURCES/0014-libsepol-cil-Check-if-name-is-a-macro-parameter-firs.patch

212ad1
From 8d7ed6eb2c396d64b1a8f6d516cb9f6f86ba2ece Mon Sep 17 00:00:00 2001
212ad1
From: James Carter <jwcart2@gmail.com>
212ad1
Date: Wed, 4 Mar 2020 16:28:11 -0500
212ad1
Subject: [PATCH] libsepol/cil: Check if name is a macro parameter first
212ad1
212ad1
Type transition file names are stored in a symbol table. Before the
212ad1
name is added, the symbol table is searched to see if the name had
212ad1
already been inserted. If it has, then the already existing datum is
212ad1
returned. If it has not, then the name is added if either the
212ad1
typetransition rule does not occur in a macro or the name is not one
212ad1
of the macro parameters.
212ad1
212ad1
Checking for a previous insertion before checking if the name is a
212ad1
macro parameter can cause a macro parameter to be treated as the
212ad1
actual name if a previous type transition file name is the same as
212ad1
the parameter.
212ad1
212ad1
Now check the name to see if it a macro paramter before checking for
212ad1
its existence in the symbol table.
212ad1
212ad1
Signed-off-by: James Carter <jwcart2@gmail.com>
212ad1
Acked-by: Ondrej Mosnacek <omosnace@redhat.com>
212ad1
---
212ad1
 libsepol/cil/src/cil_resolve_ast.c | 16 ++++++++--------
212ad1
 1 file changed, 8 insertions(+), 8 deletions(-)
212ad1
212ad1
diff --git a/libsepol/cil/src/cil_resolve_ast.c b/libsepol/cil/src/cil_resolve_ast.c
212ad1
index 979fa17d..ae334620 100644
212ad1
--- a/libsepol/cil/src/cil_resolve_ast.c
212ad1
+++ b/libsepol/cil/src/cil_resolve_ast.c
212ad1
@@ -76,14 +76,6 @@ static struct cil_name * __cil_insert_name(struct cil_db *db, hashtab_key_t key,
212ad1
 	enum cil_sym_index sym_index;
212ad1
 	struct cil_symtab_datum *datum = NULL;
212ad1
 
212ad1
-	cil_flavor_to_symtab_index(CIL_NAME, &sym_index);
212ad1
-	symtab = &((struct cil_root *)db->ast->root->data)->symtab[sym_index];
212ad1
-
212ad1
-	cil_symtab_get_datum(symtab, key, &datum);
212ad1
-	if (datum != NULL) {
212ad1
-		return (struct cil_name *)datum;
212ad1
-	}
212ad1
-
212ad1
 	if (parent->flavor == CIL_CALL) {
212ad1
 		struct cil_call *call = parent->data;
212ad1
 		macro = call->macro;	
212ad1
@@ -99,6 +91,14 @@ static struct cil_name * __cil_insert_name(struct cil_db *db, hashtab_key_t key,
212ad1
 		}
212ad1
 	}
212ad1
 
212ad1
+	cil_flavor_to_symtab_index(CIL_NAME, &sym_index);
212ad1
+	symtab = &((struct cil_root *)db->ast->root->data)->symtab[sym_index];
212ad1
+
212ad1
+	cil_symtab_get_datum(symtab, key, &datum);
212ad1
+	if (datum != NULL) {
212ad1
+		return (struct cil_name *)datum;
212ad1
+	}
212ad1
+
212ad1
 	cil_name_init(&name);
212ad1
 	cil_symtab_insert(symtab, key, (struct cil_symtab_datum *)name, ast_node);
212ad1
 	cil_list_append(db->names, CIL_NAME, name);
212ad1
-- 
212ad1
2.30.2
212ad1