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

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