Blame SOURCES/0054-libsepol-cil-Destroy-the-permission-nodes-when-exiti.patch

71cd55
From 29d6a3ee4a958607fdf7c01a78b6d389ba6e8612 Mon Sep 17 00:00:00 2001
71cd55
From: James Carter <jwcart2@gmail.com>
71cd55
Date: Thu, 13 May 2021 12:36:44 -0400
71cd55
Subject: [PATCH] libsepol/cil: Destroy the permission nodes when exiting with
71cd55
 an error
71cd55
71cd55
When exiting with an error because a class or common has too many
71cd55
permissions, destroy the permission nodes.
71cd55
71cd55
This bug was found by the secilc-fuzzer.
71cd55
71cd55
Signed-off-by: James Carter <jwcart2@gmail.com>
71cd55
---
71cd55
 libsepol/cil/src/cil_build_ast.c | 2 ++
71cd55
 1 file changed, 2 insertions(+)
71cd55
71cd55
diff --git a/libsepol/cil/src/cil_build_ast.c b/libsepol/cil/src/cil_build_ast.c
71cd55
index 87043a8fa183..71f14e20e25e 100644
71cd55
--- a/libsepol/cil/src/cil_build_ast.c
71cd55
+++ b/libsepol/cil/src/cil_build_ast.c
71cd55
@@ -444,6 +444,7 @@ int cil_gen_class(struct cil_db *db, struct cil_tree_node *parse_current, struct
71cd55
 		}
71cd55
 		if (class->num_perms > CIL_PERMS_PER_CLASS) {
71cd55
 			cil_tree_log(parse_current, CIL_ERR, "Too many permissions in class '%s'", class->datum.name);
71cd55
+			cil_tree_children_destroy(ast_node);
71cd55
 			rc = SEPOL_ERR;
71cd55
 			goto exit;
71cd55
 		}
71cd55
@@ -1019,6 +1020,7 @@ int cil_gen_common(struct cil_db *db, struct cil_tree_node *parse_current, struc
71cd55
 	}
71cd55
 	if (common->num_perms > CIL_PERMS_PER_CLASS) {
71cd55
 		cil_tree_log(parse_current, CIL_ERR, "Too many permissions in common '%s'", common->datum.name);
71cd55
+		cil_tree_children_destroy(ast_node);
71cd55
 		rc = SEPOL_ERR;
71cd55
 		goto exit;
71cd55
 	}
71cd55
-- 
71cd55
2.32.0
71cd55