libsepol/cil: do not use an uninitialized value in __cil_fqn_qualify_blocks
PATCH 1/2 libsepol/cil: do not use an uninitialized value in __cil_fqn_qualify_blocks
In __cil_fqn_qualify_blocks(), when newlen >= CIL_MAX_NAME_LENGTH, cil_tree_log() is called with child_args.node as argument but this value has not been initialized yet. Use local variable node instead, which is initialized early enough in the function.
This issue has been found using clang's static analyzer.
--- libsepol/cil/src/cil_fqn.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
libsepol/cil/src/cil_fqn.c +1 -1
@@ -121,7 +121,7 @@ static int __cil_fqn_qualify_blocks(__attribute__((unused)) hashtab_key_t k, has exit:if (rc !=SEPOL_OK ) { -cil_tree_log (child_args.node,CIL_ERR ,"Problem qualifying names in block" ); +cil_tree_log (node,CIL_ERR ,"Problem qualifying names in block" ); }return rc;
Signature · 1 line
2.12.2
PATCH 2/2 libselinux: close the subs file if fstat failed
selabel_subs_init() returned without closing cfg when a call to fstat() failed. Fix this.
--- libselinux/src/label.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
libselinux/src/label.c +1 -1
@@ -104,7 +104,7 @@ struct selabel_sub *selabel_subs_init(const char *path,return list;if (fstat (fileno (cfg), &sb) <0 ) -return list; + goto out;while (fgets_unlocked (buf,sizeof (buf) -1 , cfg)) {char *ptr =NULL ;
Signature · 1 line
2.12.2
Stephen Smalley
AppliedRe: [PATCH 2/2] libselinux: close the subs file if fstat failed
Quoted 5 lines · Nicolas Iooss
selabel_subs_init()returned without closing cfg when a call tofstat()
failed. Fix this.Signed-off-by Nicolas Iooss <[email protected]>
Thanks, applied both patches.
Quoted 18 lines
---
libselinux/src/label.c | 2 +-1 file changed, 1 insertion(+), 1 deletion(-)libselinux/src/label.c +0
-0@@ -104,7 +104,7 @@ struct selabel_sub *selabel_subs_init(const char *path, return list;
if (fstat(fileno(cfg), &sb)< 0)libselinux/src/label.c +1
-1-return list; + goto out;
while (fgets_unlocked(buf, sizeof(buf) - 1, cfg)) { char *ptr = NULL;