libsepol: fix policydb_read for policy versions < 24
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.
Signed-off-by Stephen Smalley <[email protected]>
--- libsepol/src/policydb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
libsepol/src/policydb.c +1 -1
@@ -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