Re: [PATCH] libselinux: Close leaked FILEs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Mar 11, 2022 at 5:10 PM Petr Lautrbach <plautrba@xxxxxxxxxx> wrote:
>
> Fixes:
> label_media.c:94:24: warning: leak of FILE ‘fopen (path_28, "re")’ [CWE-775] [-Wanalyzer-file-leak]
> label_x.c:121:24: warning: leak of FILE ‘fopen (path_28, "re")’ [CWE-775] [-Wanalyzer-file-leak]
>
> Signed-off-by: Petr Lautrbach <plautrba@xxxxxxxxxx>

Acked-by: James Carter <jwcart2@xxxxxxxxx>

> ---
>  libselinux/src/label_media.c | 4 ++--
>  libselinux/src/label_x.c     | 4 ++--
>  2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/libselinux/src/label_media.c b/libselinux/src/label_media.c
> index eb27deaf510e..3137c18edc19 100644
> --- a/libselinux/src/label_media.c
> +++ b/libselinux/src/label_media.c
> @@ -95,10 +95,10 @@ static int init(struct selabel_handle *rec, const struct selinux_opt *opts,
>         __fsetlocking(fp, FSETLOCKING_BYCALLER);
>
>         if (fstat(fileno(fp), &sb) < 0)
> -               return -1;
> +               goto finish;
>         if (!S_ISREG(sb.st_mode)) {
>                 errno = EINVAL;
> -               return -1;
> +               goto finish;
>         }
>         rec->spec_file = strdup(path);
>
> diff --git a/libselinux/src/label_x.c b/libselinux/src/label_x.c
> index e9fa063fafff..e6e8d9f60bff 100644
> --- a/libselinux/src/label_x.c
> +++ b/libselinux/src/label_x.c
> @@ -122,10 +122,10 @@ static int init(struct selabel_handle *rec, const struct selinux_opt *opts,
>         __fsetlocking(fp, FSETLOCKING_BYCALLER);
>
>         if (fstat(fileno(fp), &sb) < 0)
> -               return -1;
> +               goto finish;
>         if (!S_ISREG(sb.st_mode)) {
>                 errno = EINVAL;
> -               return -1;
> +               goto finish;
>         }
>         rec->spec_file = strdup(path);
>
> --
> 2.35.1
>




[Index of Archives]     [Selinux Refpolicy]     [Linux SGX]     [Fedora Users]     [Fedora Desktop]     [Yosemite Photos]     [Yosemite Camping]     [Yosemite Campsites]     [KDE Users]     [Gnome Users]

  Powered by Linux