Skip to contentSkip to conversation

Fix error path in mls_semantic_level_expand().

PATCH In review Chris PeBenito 2 participants 2 messages Feb 22, 2015 – Feb 23, 2015 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix error path in mls_semantic_level_expand().

If the level contains a category that is not associated with a sensitivity, the code correctly detects the condition, but does not return an error.

---
 libsepol/src/expand.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
libsepol/src/expand.c +2 -1
index 467f7a7..3193ef5 100644
@@ -914,10 +914,11 @@ int mls_semantic_level_expand(mls_semantic_level_t * sl, mls_level_t * l,
 		}
 		for (i = cat->low - 1; i < cat->high; i++) {
 			if (!ebitmap_get_bit(&levdatum->level->cat, i)) {
-				ERR(h, "Category %s can not be associate with "
+				ERR(h, "Category %s can not be associated with "
 				    "level %s",
 				    p->p_cat_val_to_name[i],
 				    p->p_sens_val_to_name[l->sens - 1]);
+				return -1;
 			}
 			if (ebitmap_set_bit(&l->cat, i, 1)) {
 				ERR(h, "Out of memory!");
Signature · 1 line
2.3.0
Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Chris PeBenito

If the level contains a category that is not associated with a sensitivity, the code correctly detects the condition, but does not return an error.

Thanks!

Quoted 22 lines
---
 libsepol/src/expand.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
libsepol/src/expand.c +2 -1
index 467f7a7..3193ef5 100644
@@ -914,10 +914,11 @@ int mls_semantic_level_expand(mls_semantic_level_t * sl, mls_level_t * l,
 		}
 		for (i = cat->low - 1; i < cat->high; i++) {
 			if (!ebitmap_get_bit(&levdatum->level->cat, i)) {
-				ERR(h, "Category %s can not be associate with "
+				ERR(h, "Category %s can not be associated with "
 				    "level %s",
 				    p->p_cat_val_to_name[i],
 				    p->p_sens_val_to_name[l->sens - 1]);
+				return -1;
 			}
 			if (ebitmap_set_bit(&l->cat, i, 1)) {
 				ERR(h, "Out of memory!");