[PATCH] libsepol: Print info nodes at the first child

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



cil_write_src_info_node has been called with
__write_cil_ast_node_helper, but that may break the result CIL file in
case there are no children for the info node, because the "lme" marker
is printed with __write_cil_ast_last_child_helper.

This change moves the cil_write_src_info_node call to
__write_cil_ast_first_child_helper, so opening markers and closing
markers always match.

Signed-off-by: Inseob Kim <inseob@xxxxxxxxxx>
---
 libsepol/cil/src/cil_write_ast.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libsepol/cil/src/cil_write_ast.c b/libsepol/cil/src/cil_write_ast.c
index 15d8bbaf..7f41387f 100644
--- a/libsepol/cil/src/cil_write_ast.c
+++ b/libsepol/cil/src/cil_write_ast.c
@@ -1623,7 +1623,6 @@ static int __write_cil_ast_node_helper(struct cil_tree_node *node, uint32_t *fin
 	struct cil_write_ast_args *args = extra_args;
 
 	if (node->flavor == CIL_SRC_INFO) {
-		cil_write_src_info_node(args->out, node);
 		return SEPOL_OK;
 	}
 
@@ -1643,6 +1642,10 @@ static int __write_cil_ast_first_child_helper(struct cil_tree_node *node, void *
 	struct cil_write_ast_args *args = extra_args;
 	struct cil_tree_node *parent = node->parent;
 
+	if (parent->flavor == CIL_SRC_INFO) {
+		cil_write_src_info_node(args->out, parent);
+	}
+
 	if (parent->flavor != CIL_SRC_INFO && parent->flavor != CIL_ROOT) {
 		args->depth++;
 	}
-- 
2.49.0.rc1.451.g8f38331e32-goog





[Index of Archives]     [Selinux Refpolicy]     [Linux SGX]     [Fedora Users]     [Fedora Desktop]     [Yosemite Photos]     [Yosemite Camping]     [Yosemite Campsites]     [KDE Users]     [Gnome Users]

  Powered by Linux