Re: [PATCH] Fix double-free in secilcheck
James Carter <[email protected]>
| Newsgroups | org.kernel.vger.selinux |
|---|---|
| Message-ID | <CAP+JOzTW=-B++YZ9EgXQW7aCDWvE2e51dDsr89NkYinh2mThgw@mail.gmail.com> |
On Tue, Jul 7, 2026 at 8:21 AM Cathy Hu <[email protected]> wrote: > > 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 > ``` > > Signed-off-by: Cathy Hu <[email protected]> Acked-by: James Carter <[email protected]> > --- > secilc/secilcheck.c | 1 - > 1 file changed, 1 deletion(-) > > diff --git a/secilc/secilcheck.c b/secilc/secilcheck.c > index ee141bc0..b7c32bc6 100644 > --- a/secilc/secilcheck.c > +++ b/secilc/secilcheck.c > @@ -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 > >