Skip to contentSkip to conversation

libsepol/cil: do not use an uninitialized value in __cil_fqn_qualify_blocks

PATCH Applied Nicolas Iooss 2 participants 3 messages May 12, 2017 – May 15, 2017 SELinux security module

lore
Share & tools
lore
#0 lore raw

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
index dad13474c823..717358a24eb7 100644
@@ -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
#1 lore raw

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
index 0e43474c352e..71a273bdeb2a 100644
@@ -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
#2 lore raw

Re: [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 to fstat()
failed. Fix this.

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
index 0e43474c352e..71a273bdeb2a 100644
@@ -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;