Skip to contentSkip to conversation

libsepol: Turn assert into error in type_set_expand()

PATCH In review James Carter 2 participants 3 messages Jul 30 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 libsepol: Turn assert into error in type_set_expand()

The assertion in function type_set_expand() can only be violated by a malformed policy. Since it is called before the policy has been validated just return an error.

---
v2: Do not delete the continue

 libsepol/src/expand.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
libsepol/src/expand.c +2 -1
index 8d7fe519..7883dbc5 100644
@@ -2827,7 +2827,8 @@ int type_set_expand(type_set_t *set, ebitmap_t *t, policydb_t *p,
 		for (i = 0; i < p->p_types.nprim; i++) {
 			if (p->type_val_to_struct[i] &&
 			    p->type_val_to_struct[i]->flavor == TYPE_ATTRIB) {
-				assert(!ebitmap_get_bit(t, i));
+				if (ebitmap_get_bit(t, i))
+					goto err_neg;
 				continue;
 			}
 			if (ebitmap_get_bit(t, i)) {
Signature · 1 line
2.55.0