libsepol: Print info nodes at the first child
PATCH 1/1 libsepol: Print info nodes at the first child
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 <[email protected]>
--- libsepol/cil/src/cil_write_ast.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
libsepol/cil/src/cil_write_ast.c +4 -1
@@ -1623,7 +1623,6 @@ static int __write_cil_ast_node_helper(struct cil_tree_node *node, uint32_t *finstruct 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++; }
Signature · 1 line
2.49.0.rc1.451.g8f38331e32-goog