libsepol/cil: Fix detected RESOURCE_LEAK (CWE-772)
PATCH 1/1 libsepol/cil: Fix detected RESOURCE_LEAK (CWE-772)
libsepol-3.6/cil/src/cil_binary.c:902: alloc_fn: Storage is returned from allocation function "cil_malloc". libsepol-3.6/cil/src/cil_binary.c:902: var_assign: Assigning: "mls_level" = storage returned from "cil_malloc(24UL)". libsepol-3.6/cil/src/cil_binary.c:903: noescape: Resource "mls_level" is not freed or pointed-to in "mls_level_init". libsepol-3.6/cil/src/cil_binary.c:905: noescape: Resource "mls_level" is not freed or pointed-to in "mls_level_cpy". libsepol-3.6/cil/src/cil_binary.c:919: leaked_storage: Variable "mls_level" going out of scope leaks the storage it points to.
--- libsepol/cil/src/cil_binary.c | 1 + 1 file changed, 1 insertion(+)
libsepol/cil/src/cil_binary.c +1 -0
@@ -904,6 +904,7 @@ static int cil_sensalias_to_policydb(policydb_t *pdb, struct cil_alias *cil_alia rc =mls_level_cpy (mls_level, sepol_level->level);if (rc !=SEPOL_OK ) { +free (mls_level); goto exit; } sepol_alias->level = mls_level;
Signature · 1 line
2.43.0
Quoted 8 lines · Vit Mojzis
libsepol-3.6/cil/src/cil_binary.c:902:alloc_fn: Storage is returned from allocation function "cil_malloc".libsepol-3.6/cil/src/cil_binary.c:902:var_assign: Assigning: "mls_level" = storage returned from "cil_malloc(24UL)".libsepol-3.6/cil/src/cil_binary.c:903: noescape: Resource "mls_level" is not freed or pointed-to in "mls_level_init".libsepol-3.6/cil/src/cil_binary.c:905: noescape: Resource "mls_level" is not freed or pointed-to in "mls_level_cpy".libsepol-3.6/cil/src/cil_binary.c:919:leaked_storage: Variable "mls_level" going out of scope leaks the storage it points to.Signed-off-by Vit Mojzis <[email protected]>
Quoted 20 lines
--- libsepol/cil/src/cil_binary.c | 1 + 1 file changed, 1 insertion(+)libsepol/cil/src/cil_binary.c +1
-1@@ -904,6 +904,7 @@ static int cil_sensalias_to_policydb(policydb_t *pdb, struct cil_alias *cil_alia rc =mls_level_cpy (mls_level, sepol_level->level);if (rc !=SEPOL_OK ) { +free (mls_level); goto exit; } sepol_alias->level = mls_level; --2.43.0
Quoted 9 lines · James Carter
Quoted 7 lines · Vit Mojzis
libsepol-3.6/cil/src/cil_binary.c:902:alloc_fn: Storage is returned from allocation function "cil_malloc".libsepol-3.6/cil/src/cil_binary.c:902:var_assign: Assigning: "mls_level" = storage returned from "cil_malloc(24UL)".libsepol-3.6/cil/src/cil_binary.c:903: noescape: Resource "mls_level" is not freed or pointed-to in "mls_level_init".libsepol-3.6/cil/src/cil_binary.c:905: noescape: Resource "mls_level" is not freed or pointed-to in "mls_level_cpy".libsepol-3.6/cil/src/cil_binary.c:919:leaked_storage: Variable "mls_level" going out of scope leaks the storage it points to.
Quoted 4 lines
Quoted 1 line
Signed-off-by Vit Mojzis <[email protected]>Acked-by James Carter <[email protected]>
Merged.
Thanks,
Jim
Quoted 20 lines
Quoted 20 lines
--- libsepol/cil/src/cil_binary.c | 1 + 1 file changed, 1 insertion(+)libsepol/cil/src/cil_binary.c +1
-1@@ -904,6 +904,7 @@ static int cil_sensalias_to_policydb(policydb_t *pdb, struct cil_alias *cil_alia rc =mls_level_cpy (mls_level, sepol_level->level);if (rc !=SEPOL_OK ) { +free (mls_level); goto exit; } sepol_alias->level = mls_level; --2.43.0