Skip to contentSkip to conversation

libsepol: fix policydb_read for policy versions < 24

PATCH New Stephen Smalley 1 participant 1 message Jul 16, 2015 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libsepol: fix policydb_read for policy versions < 24

Policy versions < 24 did not include type attributes in the types symtab, so there can be holes in the type_val_to_struct array. Fixes a segfault during the downgrade test performed by a make test in libsepol.

---
 libsepol/src/policydb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libsepol/src/policydb.c +1 -1
index 670aef8..665f7a9 100644
@@ -3936,7 +3936,7 @@ int policydb_read(policydb_t * p, struct policy_file *fp, unsigned verbose)
 			/* add the type itself as the degenerate case */
 			if (ebitmap_set_bit(&p->type_attr_map[i], i, 1))
 				goto bad;
-			if (p->type_val_to_struct[i]->flavor != TYPE_ATTRIB) {
+			if (p->type_val_to_struct[i] && p->type_val_to_struct[i]->flavor != TYPE_ATTRIB) {
 				if (ebitmap_set_bit(&p->attr_type_map[i], i, 1))
 					goto bad;
 			}
Signature · 1 line
2.1.0