Skip to contentSkip to conversation

Fix double-free in secilcheck

PATCH In review Cathy Hu 3 participants 3 messages Jul 7 – Jul 10 SELinux security module

lore
Share & tools
lore

Cathy Hu

author
#0 lore raw

PATCH 1/1 Fix double-free in secilcheck

If the file size of the cil file is zero, fclose was called twice.

Fixes:

```
localhost:~ # touch ~/.empty.cil
localhost:~ # secilcheck  /etc/selinux/targeted/policy/policy.35 ./empty.cil
free(): double free detected in tcache 2
Aborted                    (core dumped) secilcheck /etc/selinux/targeted/policy/policy.35 ./empty.cil
```
---
 secilc/secilcheck.c | 1 -
 1 file changed, 1 deletion(-)
secilc/secilcheck.c +0 -1
index ee141bc0..b7c32bc6 100644
@@ -155,7 +155,6 @@ static int add_cil_file(const char *filename, struct cil_db *cdb)
 	file_size = filedata.st_size;
 
 	if (!file_size) {
-		fclose(file);
 		rc = 0;
 		goto exit;
 	}
Signature · 1 line
2.54.0
Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Cathy Hu

If the file size of the cil file is zero, fclose was called twice.

Fixes:

Quoted 8 lines
```
localhost:~ # touch ~/.empty.cil
localhost:~ # secilcheck  /etc/selinux/targeted/policy/policy.35 ./empty.cil
free(): double free detected in tcache 2
Aborted                    (core dumped) secilcheck /etc/selinux/targeted/policy/policy.35 ./empty.cil
```
Quoted 20 lines
---
 secilc/secilcheck.c | 1 -
 1 file changed, 1 deletion(-)
secilc/secilcheck.c +0 -2
index ee141bc0..b7c32bc6 100644
@@ -155,7 +155,6 @@ static int add_cil_file(const char *filename, struct cil_db *cdb)
        file_size = filedata.st_size;
 
        if (!file_size) {
-               fclose(file);
                rc = 0;
                goto exit;
        }
--

2.54.0

maintainer
#2 lore raw
Quoted 13 lines · James Carter
Quoted 11 lines · Cathy Hu

If the file size of the cil file is zero, fclose was called twice.

Fixes:

```
localhost:~ # touch ~/.empty.cil
localhost:~ # secilcheck  /etc/selinux/targeted/policy/policy.35 ./empty.cil
free(): double free detected in tcache 2
Aborted                    (core dumped) secilcheck /etc/selinux/targeted/policy/policy.35 ./empty.cil
```
Quoted 3 lines
Quoted 1 line

Thanks, merged.

Quoted 22 lines
Quoted 21 lines
---
 secilc/secilcheck.c | 1 -
 1 file changed, 1 deletion(-)
secilc/secilcheck.c +0 -2
index ee141bc0..b7c32bc6 100644
@@ -155,7 +155,6 @@ static int add_cil_file(const char *filename, struct cil_db *cdb)
        file_size = filedata.st_size;
 
        if (!file_size) {
-               fclose(file);
                rc = 0;
                goto exit;
        }
--

2.54.0