libsepol/cil: Need to add to the length rather assigning it
PATCH 1/1 libsepol/cil: Need to add to the length rather assigning it
When writing a policy.conf constrain expression from a CIL policy all user attributes need to be expanded. This includes lists containing users and user attributes. When trying to determine the length of such a list the calculated length of the users in an attribute was being assigned as the length rather than added to the length.
Add to the length in this case instead of merely assigning it.
--- libsepol/cil/src/cil_policy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
libsepol/cil/src/cil_policy.c +1 -1
@@ -384,7 +384,7 @@ static size_t __cil_cons_leaf_operand_len(struct cil_db *db,cil_list_for_each (i1, (struct cil_list *)operand->data) {struct cil_tree_node *node =NODE (i1->data);if (node->flavor ==CIL_USERATTRIBUTE ) { - len =__cil_userattribute_len (db, node->data); + len +=__cil_userattribute_len (db, node->data); }else { len +=strlen (DATUM (node->data)->fqn); len++;/* " " or "}" */
Signature · 1 line
2.54.0
Quoted 11 lines · James Carter
When writing a policy.conf constrain expression from a CIL policy all user attributes need to be expanded. This includes lists containing users and user attributes. When trying to determine the length of such a list the calculated length of the users in an attribute was being assigned as the length rather than added to the length.
Add to the length in this case instead of merely assigning it.
Signed-off-by James Carter <[email protected]>
Quoted 21 lines
--- libsepol/cil/src/cil_policy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)libsepol/cil/src/cil_policy.c +1
-2@@ -384,7 +384,7 @@ static size_t __cil_cons_leaf_operand_len(struct cil_db *db,cil_list_for_each (i1, (struct cil_list *)operand->data) {struct cil_tree_node *node =NODE (i1->data);if (node->flavor ==CIL_USERATTRIBUTE ) { - len =__cil_userattribute_len (db, node->data); + len +=__cil_userattribute_len (db, node->data); }else { len +=strlen (DATUM (node->data)->fqn); len++;/* " " or "}" */ --2.54.0
Stephen Smalley
maintainerQuoted 10 lines · Stephen Smalley
Quoted 8 lines · James Carter
When writing a policy.conf constrain expression from a CIL policy all user attributes need to be expanded. This includes lists containing users and user attributes. When trying to determine the length of such a list the calculated length of the users in an attribute was being assigned as the length rather than added to the length.
Quoted 5 lines
Quoted 3 lines
Add to the length in this case instead of merely assigning it.
Signed-off-by James Carter <[email protected]>Acked-by Stephen Smalley <[email protected]>
Merged.
Quoted 22 lines
Quoted 22 lines
--- libsepol/cil/src/cil_policy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)libsepol/cil/src/cil_policy.c +1
-2@@ -384,7 +384,7 @@ static size_t __cil_cons_leaf_operand_len(struct cil_db *db,cil_list_for_each (i1, (struct cil_list *)operand->data) {struct cil_tree_node *node =NODE (i1->data);if (node->flavor ==CIL_USERATTRIBUTE ) { - len =__cil_userattribute_len (db, node->data); + len +=__cil_userattribute_len (db, node->data); }else { len +=strlen (DATUM (node->data)->fqn); len++;/* " " or "}" */ --2.54.0