Skip to contentSkip to conversation

checkpolicy: free role identifier in define_role_dom()

PATCH In review Christian Göttsche 2 participants 2 messages Jul 6, 2023 – Jul 14, 2023 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 checkpolicy: free role identifier in define_role_dom()

Free the role identifier in case the role has been already defined beforehand, since in that case the identifier is not stored via declare_symbol().

---
Triggered by the checkpolicy round-trip patch in the GitHub CI.

---
 checkpolicy/policy_define.c | 4 ++++
 1 file changed, 4 insertions(+)
checkpolicy/policy_define.c +4 -0
index cef8f3c4..e10c92ff 100644
@@ -3045,7 +3045,11 @@ role_datum_t *define_role_dom(role_datum_t * r)
 			yyerror("Out of memory!");
 			goto cleanup;
 		}
+	} else {
+		free(role_id);
+		role_id = NULL;
 	}
+
 	if (r) {
 		ebitmap_t types;
 		ebitmap_init(&types);
Signature · 1 line
2.40.1
#1 lore raw
Quoted 6 lines · Christian Göttsche

Free the role identifier in case the role has been already defined beforehand, since in that case the identifier is not stored via declare_symbol().

The right answer here is to just remove role dominance from checkpolicy. I've sent a patch to the list. Thanks,
Jim

Quoted 25 lines

---
Triggered by the checkpolicy round-trip patch in the GitHub CI.

---
 checkpolicy/policy_define.c | 4 ++++
 1 file changed, 4 insertions(+)
checkpolicy/policy_define.c +4 -1
index cef8f3c4..e10c92ff 100644
@@ -3045,7 +3045,11 @@ role_datum_t *define_role_dom(role_datum_t * r)
                        yyerror("Out of memory!");
                        goto cleanup;
                }
+       } else {
+               free(role_id);
+               role_id = NULL;
        }
+
        if (r) {
                ebitmap_t types;
                ebitmap_init(&types);
--

2.40.1