mirror of
https://github.com/topjohnwu/selinux.git
synced 2024-11-27 13:30:48 +00:00
libsepol: Fix detected RESOURCE_LEAKs
Fixes: Error: RESOURCE_LEAK (CWE-772): [#def5] libsepol/src/kernel_to_cil.c:2380: alloc_arg: "strs_init" allocates memory that is stored into "strs". libsepol/src/kernel_to_cil.c:2386: noescape: Resource "strs" is not freed or pointed-to in "strs_add". libsepol/src/kernel_to_cil.c:2386: noescape: Resource "strs" is not freed or pointed-to in "strs_add". libsepol/src/kernel_to_cil.c:2386: noescape: Resource "strs" is not freed or pointed-to in "strs_add". libsepol/src/kernel_to_cil.c:2507: leaked_storage: Variable "strs" going out of scope leaks the storage it points to. libsepol/src/kernel_to_conf.c:2315: alloc_arg: "strs_init" allocates memory that is stored into "strs". libsepol/src/kernel_to_conf.c:2321: noescape: Resource "strs" is not freed or pointed-to in "strs_add". libsepol/src/kernel_to_conf.c:2321: noescape: Resource "strs" is not freed or pointed-to in "strs_add". libsepol/src/kernel_to_conf.c:2321: noescape: Resource "strs" is not freed or pointed-to in "strs_add". libsepol/src/kernel_to_conf.c:2385: leaked_storage: Variable "strs" going out of scope leaks the storage it points to. Signed-off-by: Petr Lautrbach <plautrba@redhat.com> Acked-by: James Carter <jwcart2@gmail.com>
This commit is contained in:
parent
f3265d5802
commit
c304156133
@ -2497,9 +2497,10 @@ static int write_user_decl_rules_to_cil(FILE *out, struct policydb *pdb)
|
||||
sepol_printf(out, ")\n");
|
||||
}
|
||||
|
||||
strs_destroy(&strs);
|
||||
|
||||
exit:
|
||||
if (strs)
|
||||
strs_destroy(&strs);
|
||||
|
||||
if (rc != 0) {
|
||||
sepol_log_err("Error writing user declarations to CIL\n");
|
||||
}
|
||||
|
@ -2375,9 +2375,10 @@ static int write_user_decl_rules_to_conf(FILE *out, struct policydb *pdb)
|
||||
sepol_printf(out, ";\n");
|
||||
}
|
||||
|
||||
strs_destroy(&strs);
|
||||
|
||||
exit:
|
||||
if (strs)
|
||||
strs_destroy(&strs);
|
||||
|
||||
if (rc != 0) {
|
||||
sepol_log_err("Error writing user declarations to policy.conf\n");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user