libsepol: Turn assert into error in type_set_expand()
PATCH 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.
--- libsepol/src/expand.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
libsepol/src/expand.c +2 -2
@@ -2827,8 +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)); -continue ; +if (ebitmap_get_bit (t, i)) + goto err_neg; }if (ebitmap_get_bit (t, i)) {if (ebitmap_set_bit (t, i,0 ))
Signature · 1 line
2.55.0
Stephen Smalley
maintainerQuoted 15 lines · James Carter
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.Signed-off-by James Carter <[email protected]>--- libsepol/src/expand.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)libsepol/src/expand.c +0
-0
libsepol/src/expand.c int type_set_expand(type_set_t *set, ebitmap_t *t, policydb_t *p, · line 2831
Quoted 7 lines
libsepol/src/expand.c +2
-2@@ -2827,8 +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)); -continue ; +if (ebitmap_get_bit (t, i)) + goto err_neg;
Why did you drop the continue; in the non-error path?
Quoted 6 lines
libsepol/src/expand.c +0
-1}if (ebitmap_get_bit (t, i)) {if (ebitmap_set_bit (t, i,0 )) --2.55.0
Quoted 12 lines · Stephen Smalley
Quoted 10 lines · James Carter
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.Signed-off-by James Carter <[email protected]>--- libsepol/src/expand.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 14 lines
libsepol/src/expand.c int type_set_expand(type_set_t *set, ebitmap_t *t, policydb_t *p, · line 2831
Quoted 12 lines
libsepol/src/expand.c +2
-2@@ -2827,8 +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)); -continue ; +if (ebitmap_get_bit (t, i)) + goto err_neg;Why did you drop the continue; in the non-error path?
That was a mistake. I'll send out a correction.
Jim
Quoted 7 lines
Quoted 7 lines
libsepol/src/expand.c +0
-1}if (ebitmap_get_bit (t, i)) {if (ebitmap_set_bit (t, i,0 )) --2.55.0