libsepol: Fix markers for info nodes w/o children
PATCH 1/1 libsepol: Fix markers for info nodes w/o children
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 manually prints the "lme" marker in __write_cil_ast_node_helper in case there are no children, so opening markers and closing markers always match regardless of children.
--- libsepol/cil/src/cil_write_ast.c | 4 ++++ 1 file changed, 4 insertions(+)
libsepol/cil/src/cil_write_ast.c +4 -0
@@ -1624,6 +1624,10 @@ static int __write_cil_ast_node_helper(struct cil_tree_node *node, uint32_t *finif (node->flavor ==CIL_SRC_INFO ) {cil_write_src_info_node (args->out, node); + +if (node->cl_head ==NULL ) { +fprintf (args->out,";;* lme\n" ); + }return SEPOL_OK ; }
Signature · 1 line
2.49.0.504.g3bcea36a83-goog
Quoted 11 lines · Inseob Kim
cil_write_src_info_nodehas 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 manually prints the "lme" marker in
__write_cil_ast_node_helperin case there are no children, so opening markers and closing markers always match regardless of children.Signed-off-by Inseob Kim <[email protected]>
Quoted 23 lines
--- libsepol/cil/src/cil_write_ast.c | 4 ++++ 1 file changed, 4 insertions(+)libsepol/cil/src/cil_write_ast.c +4
-1@@ -1624,6 +1624,10 @@ static int __write_cil_ast_node_helper(struct cil_tree_node *node, uint32_t *finif (node->flavor ==CIL_SRC_INFO ) {cil_write_src_info_node (args->out, node); + +if (node->cl_head ==NULL ) { +fprintf (args->out,";;* lme\n" ); + }return SEPOL_OK ; } --2.49.0.504.g3bcea36a83-goog
Quoted 8 lines · James Carter
Quoted 6 lines · Inseob Kim
cil_write_src_info_nodehas 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.
Quoted 8 lines
Quoted 5 lines
This change manually prints the "lme" marker in
__write_cil_ast_node_helperin case there are no children, so opening markers and closing markers always match regardless of children.Signed-off-by Inseob Kim <[email protected]>Acked-by James Carter <[email protected]>
Merged.
Thanks,
Jim
Quoted 23 lines
Quoted 23 lines
--- libsepol/cil/src/cil_write_ast.c | 4 ++++ 1 file changed, 4 insertions(+)libsepol/cil/src/cil_write_ast.c +4
-1@@ -1624,6 +1624,10 @@ static int __write_cil_ast_node_helper(struct cil_tree_node *node, uint32_t *finif (node->flavor ==CIL_SRC_INFO ) {cil_write_src_info_node (args->out, node); + +if (node->cl_head ==NULL ) { +fprintf (args->out,";;* lme\n" ); + }return SEPOL_OK ; } --2.49.0.504.g3bcea36a83-goog